Merge branch 'master' of github.com:floodlight/loxigen
Conflicts:
java_gen/templates/of_factory_interface.java
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/util/ActionUtils.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/util/ActionUtils.java
new file mode 100644
index 0000000..e0553a9
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/util/ActionUtils.java
@@ -0,0 +1,43 @@
+package org.projectfloodlight.openflow.util;
+
+import java.util.List;
+
+import org.projectfloodlight.openflow.protocol.OFFlowMod;
+import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFInstructionType;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+import org.projectfloodlight.openflow.protocol.action.OFAction;
+import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
+import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
+
+import com.google.common.collect.ImmutableList;
+
+public class ActionUtils {
+ private ActionUtils() {}
+
+ public static List<OFAction> getActions(OFFlowStatsEntry e) {
+ if(e.getVersion() == OFVersion.OF_10) {
+ return e.getActions();
+ } else {
+ for(OFInstruction i: e.getInstructions()) {
+ if(i.getType() == OFInstructionType.APPLY_ACTIONS) {
+ return ((OFInstructionApplyActions) i).getActions();
+ }
+ }
+ return ImmutableList.of();
+ }
+ }
+
+ public static List<OFAction> getActions(OFFlowMod e) {
+ if(e.getVersion() == OFVersion.OF_10) {
+ return e.getActions();
+ } else {
+ for(OFInstruction i: e.getInstructions()) {
+ if(i.getType() == OFInstructionType.APPLY_ACTIONS) {
+ return ((OFInstructionApplyActions) i).getActions();
+ }
+ }
+ return ImmutableList.of();
+ }
+ }
+}
diff --git a/java_gen/templates/of_factory_class.java b/java_gen/templates/of_factory_class.java
index 9352541..af0777d 100644
--- a/java_gen/templates/of_factory_class.java
+++ b/java_gen/templates/of_factory_class.java
@@ -174,4 +174,7 @@
}
//:: #endif
+ public OFVersion getVersion() {
+ return OFVersion.${factory.version.constant_version};
+ }
}
diff --git a/java_gen/templates/of_factory_interface.java b/java_gen/templates/of_factory_interface.java
index c4ec8af..17fe884 100644
--- a/java_gen/templates/of_factory_interface.java
+++ b/java_gen/templates/of_factory_interface.java
@@ -60,6 +60,7 @@
OFVersion getOFVersion();
OFMessageReader<${factory.base_class}> getReader();
+ OFVersion getVersion();
//:: if factory.name == 'OFOxms':
public <F extends OFValueType<F>> OFOxm<F> fromValue(F value, MatchField<F> field);