Package renaming - missed the pre-written files in the previous commit.
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQT.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQT.java
new file mode 100644
index 0000000..ff077ce
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQT.java
@@ -0,0 +1,5 @@
+package org.projectfloodlight.openflow.protocol;
+
+public class OFBsnVportQInQT {
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMatchBmap.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMatchBmap.java
new file mode 100644
index 0000000..e17796a
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMatchBmap.java
@@ -0,0 +1,5 @@
+package org.projectfloodlight.openflow.protocol;
+
+public class OFMatchBmap {
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMessageReader.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMessageReader.java
new file mode 100644
index 0000000..8837867
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMessageReader.java
@@ -0,0 +1,8 @@
+package org.projectfloodlight.openflow.protocol;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+
+public interface OFMessageReader<T> {
+ T readFrom(ChannelBuffer bb) throws OFParseError;
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMessageWriter.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMessageWriter.java
new file mode 100644
index 0000000..bec5634
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFMessageWriter.java
@@ -0,0 +1,8 @@
+package org.projectfloodlight.openflow.protocol;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+
+public interface OFMessageWriter<T> {
+ public void write(ChannelBuffer bb, T message) throws OFParseError;
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFObject.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFObject.java
new file mode 100644
index 0000000..07759d7
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFObject.java
@@ -0,0 +1,8 @@
+package org.projectfloodlight.openflow.protocol;
+
+
+/**
+ * Base interface of all OpenFlow objects (e.g., messages, actions, stats, etc.)
+ */
+public interface OFObject extends Writeable {
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFObjectFactory.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFObjectFactory.java
new file mode 100644
index 0000000..c5869ef
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFObjectFactory.java
@@ -0,0 +1,7 @@
+package org.projectfloodlight.openflow.protocol;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFObjectFactory<T extends OFObject> {
+ T read(ChannelBuffer buffer);
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFOxmList.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFOxmList.java
new file mode 100644
index 0000000..ac48c8d
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFOxmList.java
@@ -0,0 +1,128 @@
+package org.projectfloodlight.openflow.protocol;
+
+import java.util.EnumMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+import org.projectfloodlight.openflow.protocol.match.MatchField;
+import org.projectfloodlight.openflow.protocol.match.MatchFields;
+import org.projectfloodlight.openflow.types.OFValueType;
+import org.projectfloodlight.openflow.util.ChannelUtils;
+import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
+
+import com.google.common.collect.ImmutableMap;
+
+public class OFOxmList implements Iterable<OFOxm<?>>, Writeable {
+ private final Map<MatchFields, OFOxm<?>> oxmMap;
+
+ public final static OFOxmList EMPTY = new OFOxmList(ImmutableMap.<MatchFields, OFOxm<?>>of());
+
+ private OFOxmList(Map<MatchFields, OFOxm<?>> oxmMap) {
+ this.oxmMap = oxmMap;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends OFValueType<T>> OFOxm<T> get(MatchField<T> matchField) {
+ return (OFOxm<T>) oxmMap.get(matchField.id);
+ }
+
+ public static class Builder {
+ private final Map<MatchFields, OFOxm<?>> oxmMap;
+
+ public Builder() {
+ oxmMap = new EnumMap<MatchFields, OFOxm<?>>(MatchFields.class);
+ }
+
+ public Builder(EnumMap<MatchFields, OFOxm<?>> oxmMap) {
+ this.oxmMap = oxmMap;
+ }
+
+ public <T extends OFValueType<T>> void set(OFOxm<T> oxm) {
+ oxmMap.put(oxm.getMatchField().id, oxm);
+ }
+
+ public <T extends OFValueType<T>> void unset(MatchField<T> matchField) {
+ oxmMap.remove(matchField.id);
+ }
+
+ public OFOxmList build() {
+ return new OFOxmList(oxmMap);
+ }
+ }
+
+ @Override
+ public Iterator<OFOxm<?>> iterator() {
+ return oxmMap.values().iterator();
+ }
+
+ public static OFOxmList ofList(List<OFOxm<?>> oxmList) {
+ Map<MatchFields, OFOxm<?>> map = new EnumMap<MatchFields, OFOxm<?>>(
+ MatchFields.class);
+ for (OFOxm<?> o : oxmList) {
+ // TODO: if fully masked, ignore oxm.
+ map.put(o.getMatchField().id, o);
+ }
+ return new OFOxmList(map);
+ }
+
+ public static OFOxmList of(OFOxm<?>... oxms) {
+ Map<MatchFields, OFOxm<?>> map = new EnumMap<MatchFields, OFOxm<?>>(
+ MatchFields.class);
+ for (OFOxm<?> o : oxms) {
+ // TODO: if fully masked, ignore oxm.
+ map.put(o.getMatchField().id, o);
+ }
+ return new OFOxmList(map);
+ }
+
+ public static OFOxmList readFrom(ChannelBuffer bb, int length,
+ OFMessageReader<OFOxm<?>> reader) throws OFParseError {
+ return ofList(ChannelUtils.readList(bb, length, reader));
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer bb) {
+ for (OFOxm<?> o : this) {
+ o.writeTo(bb);
+ }
+ }
+
+ public OFOxmList.Builder createBuilder() {
+ return new OFOxmList.Builder(new EnumMap<MatchFields, OFOxm<?>>(oxmMap));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((oxmMap == null) ? 0 : oxmMap.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ OFOxmList other = (OFOxmList) obj;
+ if (oxmMap == null) {
+ if (other.oxmMap != null)
+ return false;
+ } else if (!oxmMap.equals(other.oxmMap))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "OFOxmList" + oxmMap;
+ }
+
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeature.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeature.java
new file mode 100644
index 0000000..b722228
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeature.java
@@ -0,0 +1,5 @@
+package org.projectfloodlight.openflow.protocol;
+
+public class OFTableFeature {
+ // FIXME implement
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFVersion.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFVersion.java
new file mode 100644
index 0000000..6f54e5f
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/OFVersion.java
@@ -0,0 +1,16 @@
+package org.projectfloodlight.openflow.protocol;
+
+public enum OFVersion {
+ OF_10(1), OF_11(2), OF_12(3), OF_13(4);
+
+ public final int wireVersion;
+
+ OFVersion(final int wireVersion) {
+ this.wireVersion = wireVersion;
+ }
+
+ public int getWireVersion() {
+ return wireVersion;
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Wildcards.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Wildcards.java
new file mode 100644
index 0000000..2268ce6
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Wildcards.java
@@ -0,0 +1,656 @@
+/**
+ * Copyright 2013, Big Switch Networks, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ **/
+
+package org.projectfloodlight.openflow.protocol;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.base.Joiner;
+
+/**
+ * a more user friendly representation of the wildcards bits in an OpenFlow
+ * match. The Wildcards object is
+ * <ul>
+ * <li>immutable (i.e., threadsafe)</li>
+ * <li>instance managed (don't instantiate it yourself), instead call "of"</li>
+ * <ul>
+ * <p>
+ * You can construct a Wildcard object from either its integer representation
+ * </p>
+ * <code>
+ * Wildcard.of(0x3820e0);
+ * </code>
+ * <p>
+ * Or start with either an empty or full wildcard, and select/unselect foo.
+ * </p>
+ * <code>
+ * Wildcard w = Wildcards.NONE
+ * .set(Flag.DL_SRC, Flag. DL_DST, Flag.DL_VLAN_PCP)
+ * .setNwDstMask(8)
+ * .setNwSrcMask(8);
+ * </code>
+ * <p>
+ * <b>Remember:</b> Wildcards objects are immutable. set... operations have
+ * <b>NO EFFECT</b> on the current wildcard object. You HAVE to use the returned
+ * changed object.
+ * </p>
+ *
+ * @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
+ */
+public class Wildcards {
+ public class OFWildcardFlags {
+ 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, 6
+ * bits).
+ */
+
+ final public static int OFPFW_ALL_SANITIZED = (((1 << 22) - 1)
+ & ~OFPFW_NW_SRC_MASK & ~OFPFW_NW_DST_MASK)
+ | OFPFW_NW_SRC_ALL
+ | OFPFW_NW_DST_ALL;
+
+
+ }
+
+ public final static Wildcards FULL = new Wildcards(OFWildcardFlags.OFPFW_ALL_SANITIZED);
+ private static final int FULL_INT = FULL.getInt();
+
+ public final static Wildcards EXACT = new Wildcards(0);
+
+ // floodlight common case: matches on inport + l2
+ public final static int INT_INPORT_L2_MATCH = 0x3820e0;
+ public final static Wildcards INPORT_L2_MATCH = new Wildcards(
+ INT_INPORT_L2_MATCH);
+
+ /**
+ * enum type for the binary flags that can be set in the wildcards field of
+ * an OFWildcardFlags. Replaces the unwieldy c-ish int constants in OFWildcardFlags.
+ */
+ public static enum Flag {
+ IN_PORT(OFWildcardFlags.OFPFW_IN_PORT), /* Switch input port. */
+ DL_VLAN(OFWildcardFlags.OFPFW_DL_VLAN), /* VLAN id. */
+ DL_SRC(OFWildcardFlags.OFPFW_DL_SRC), /* Ethernet source address. */
+ DL_DST(OFWildcardFlags.OFPFW_DL_DST), /* Ethernet destination addr */
+ DL_TYPE(OFWildcardFlags.OFPFW_DL_TYPE), /* Ethernet frame type. */
+ NW_PROTO(OFWildcardFlags.OFPFW_NW_PROTO), /* IP protocol. */
+ TP_SRC(OFWildcardFlags.OFPFW_TP_SRC), /* TCP/UDP source port. */
+ TP_DST(OFWildcardFlags.OFPFW_TP_DST), /* TCP/UDP destination port. */
+ DL_VLAN_PCP(OFWildcardFlags.OFPFW_DL_VLAN_PCP), /* VLAN priority. */
+ NW_SRC(-1) { /*
+ * virtual NW_SRC flag => translates to the strange 6 bits
+ * in the header
+ */
+ @Override
+ boolean isBolean() {
+ return false;
+ }
+
+ @Override
+ int getInt(int flags) {
+ return ((flags & OFWildcardFlags.OFPFW_NW_SRC_MASK) >> OFWildcardFlags.OFPFW_NW_SRC_SHIFT);
+ }
+
+ @Override
+ int setInt(int flags, int srcMask) {
+ return (flags & ~OFWildcardFlags.OFPFW_NW_SRC_MASK) | (srcMask << OFWildcardFlags.OFPFW_NW_SRC_SHIFT);
+ }
+
+ @Override
+ int wildcard(int flags) {
+ return flags & ~OFWildcardFlags.OFPFW_NW_SRC_MASK;
+ }
+
+ @Override
+ int matchOn(int flags) {
+ return flags | OFWildcardFlags.OFPFW_NW_SRC_ALL;
+ }
+
+ @Override
+ boolean isPartiallyOn(int flags) {
+ int intValue = getInt(flags);
+ return intValue > 0 && intValue < 32;
+ }
+
+ @Override
+ boolean isFullyOn(int flags) {
+ return getInt(flags) >= 32;
+ }
+
+ },
+ NW_DST(-1) { /*
+ * virtual NW_SRC flag => translates to the strange 6 bits
+ * in the header
+ */
+ @Override
+ boolean isBolean() {
+ return false;
+ }
+
+ @Override
+ int getInt(int flags) {
+ return ((flags & OFWildcardFlags.OFPFW_NW_DST_MASK) >> OFWildcardFlags.OFPFW_NW_DST_SHIFT);
+ }
+
+ @Override
+ int setInt(int flags, int srcMask) {
+ return (flags & ~OFWildcardFlags.OFPFW_NW_DST_MASK) | (srcMask << OFWildcardFlags.OFPFW_NW_DST_SHIFT);
+ }
+
+ @Override
+ int wildcard(int flags) {
+ return flags & ~OFWildcardFlags.OFPFW_NW_DST_MASK;
+ }
+
+ @Override
+ int matchOn(int flags) {
+ return flags | OFWildcardFlags.OFPFW_NW_DST_ALL;
+ }
+
+ @Override
+ boolean isFullyOn(int flags) {
+ return getInt(flags) >= 32;
+ }
+ },
+ NW_TOS(OFWildcardFlags.OFPFW_NW_TOS); /* IP ToS (DSCP field, 6 bits). */
+
+ final int bitPosition;
+
+ Flag(int bitPosition) {
+ this.bitPosition = bitPosition;
+ }
+
+ /**
+ * @return a modified OF-1.0 flags field with this flag cleared (match
+ * on this field)
+ */
+ int matchOn(int flags) {
+ return flags & ~this.bitPosition;
+ }
+
+ /**
+ * @return a modified OF-1.0 flags field with this flag set (wildcard
+ * this field)
+ */
+ int wildcard(int flags) {
+ return flags | this.bitPosition;
+ }
+
+ /**
+ * @return true iff this is a true boolean flag that can either be off
+ * or on.True in OF-1.0 for all fields except NW_SRC and NW_DST
+ */
+ boolean isBolean() {
+ return false;
+ }
+
+ /**
+ * @return true iff this wildcard field is currently 'partially on'.
+ * Always false for true Boolean Flags. Can be true in OF-1.0
+ * for NW_SRC, NW_DST.
+ */
+ boolean isPartiallyOn(int flags) {
+ return false;
+ }
+
+ /**
+ * @return true iff this wildcard field currently fully on (fully
+ * wildcarded). Equivalent to the boolean flag being set in the
+ * bitmask for bit flags, and to the wildcarded bit length set
+ * to >=32 for NW_SRC and NW_DST
+ * @param flags
+ * @return
+ */
+ boolean isFullyOn(int flags) {
+ return (flags & this.bitPosition) != 0;
+ }
+
+ /**
+ * set the integer representation of this flag. only for NW_SRC and
+ * NW_DST
+ */
+ int setInt(int flags, int srcMask) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * set the integer representation of this flag. only for NW_SRC and
+ * NW_DST
+ */
+ int getInt(int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ }
+
+ private final int flags;
+
+ /** private constructor. use Wildcard.of() instead */
+ private Wildcards(int flags) {
+ this.flags = flags;
+ }
+
+ /**
+ * return a wildcard object matching the given int flags. May reuse / cache
+ * frequently used wildcard instances. Don't rely on it though (use equals
+ * not ==).
+ *
+ * @param flags
+ * @return
+ */
+ public static Wildcards of(int paramFlags) {
+ int flags = paramFlags; //sanitizeInt(paramFlags);
+ switch(flags) {
+ case 0x0000:
+ return EXACT;
+ case OFWildcardFlags.OFPFW_ALL_SANITIZED:
+ return FULL;
+ case INT_INPORT_L2_MATCH:
+ return INPORT_L2_MATCH;
+ default:
+ return new Wildcards(flags);
+ }
+ }
+
+ /** convience method return a wildcard for exactly one set flag */
+ public static Wildcards of(Wildcards.Flag setFlag) {
+ return Wildcards.of(setFlag.wildcard(0));
+ }
+
+ /** convience method return a wildcard for exactly two set flags */
+ public static Wildcards of(Wildcards.Flag setFlag, Wildcards.Flag setFlag2) {
+ return Wildcards.of(setFlag.wildcard(setFlag2.wildcard(0)));
+ }
+
+ /** convience method return a wildcard for an arbitrary number of set flags */
+ public static Wildcards of(Wildcards.Flag... setFlags) {
+ int flags = 0;
+ for (Wildcards.Flag flag : setFlags)
+ flags = flag.wildcard(0);
+ return Wildcards.of(flags);
+ }
+
+ /** convience method return a wildcards for ofmatches that match on one flag */
+ public static Wildcards ofMatches(Wildcards.Flag setFlag) {
+ return Wildcards.of(setFlag.matchOn(FULL_INT));
+ }
+
+ /**
+ * convience method return a wildcard for for an ofmatch that match on two
+ * flags
+ */
+ public static Wildcards ofMatches(Wildcards.Flag setFlag, Wildcards.Flag setFlag2) {
+ return Wildcards.of(setFlag.matchOn(setFlag2.matchOn(FULL_INT)));
+ }
+
+ /**
+ * convience method return a wildcard for an ofmatch that amtch on an
+ * arbitrary number of set flags
+ */
+ public static Wildcards ofMatches(Wildcards.Flag... setFlags) {
+ int flags = FULL_INT;
+ for (Wildcards.Flag flag : setFlags)
+ flags = flag.matchOn(flags);
+ return Wildcards.of(flags);
+ }
+
+ public static Wildcards ofMatches(Set<Wildcards.Flag> wSet) {
+ int flags = FULL_INT;
+ for (Wildcards.Flag flag : wSet)
+ flags = flag.matchOn(flags);
+ return Wildcards.of(flags);
+ }
+
+ /**
+ * return a Wildcards object that has the given flags set
+ * <p>
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ */
+ public Wildcards wildcard(Wildcards.Flag flag) {
+ int flags = flag.wildcard(this.flags);
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return a Wildcards object that has the given flags set
+ * <p>
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ */
+ public Wildcards wildcard(Wildcards.Flag flag, Wildcards.Flag flag2) {
+ int flags = flag.wildcard(flag2.wildcard(this.flags));
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return a Wildcards object that has the given flags wildcarded
+ * <p>
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ */
+ public Wildcards wildcard(Wildcards.Flag... setFlags) {
+ int flags = this.flags;
+ for (Wildcards.Flag flag : setFlags)
+ flags = flag.wildcard(flags);
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return a Wildcards object that matches on exactly the given flag
+ * <p>
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ */
+ public Wildcards matchOn(Wildcards.Flag flag) {
+ int flags = flag.matchOn(this.flags);
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return a Wildcards object that matches on exactly the given flags
+ * <p>
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ */
+ public Wildcards matchOn(Wildcards.Flag flag, Wildcards.Flag flag2) {
+ int flags = flag.matchOn(flag2.matchOn(this.flags));
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return a Wildcards object that matches on exactly the given flags
+ * <p>
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ */
+ public Wildcards matchOn(Wildcards.Flag... setFlags) {
+ int flags = this.flags;
+ for (Wildcards.Flag flag : setFlags)
+ flags = flag.matchOn(flags);
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return the nw src mask in normal CIDR style, e.g., 8 means x.x.x.x/8
+ * means 8 bits wildcarded
+ */
+ public int getNwSrcMask() {
+ return Math.max(0, 32 - Flag.NW_SRC.getInt(flags));
+ }
+
+ /**
+ * return the nw dst mask in normal CIDR style, e.g., 8 means x.x.x.x/8
+ * means 8 bits wildcarded
+ */
+ public int getNwDstMask() {
+ return Math.max(0, 32 - Flag.NW_DST.getInt(flags));
+ }
+
+ /**
+ * return a Wildcard object that has the given nwSrcCidrMask set.
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ *
+ * @param srcCidrMask
+ * source mask to set in <b>normal CIDR notation</b>, i.e., 8
+ * means x.x.x.x/8
+ * @return a modified object
+ */
+ public Wildcards withNwSrcMask(int srcCidrMask) {
+ int flags = Flag.NW_SRC.setInt(this.flags, Math.max(0, 32 - srcCidrMask));
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return a Wildcard object that has the given nwDstCidrMask set.
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ *
+ * @param dstCidrMask
+ * dest mask to set in <b>normal CIDR notation</b>, i.e., 8 means
+ * x.x.x.x/8
+ * @return a modified object
+ */
+ public Wildcards withNwDstMask(int dstCidrMask) {
+ int flags = Flag.NW_DST.setInt(this.flags, Math.max(0, 32 - dstCidrMask));
+ if (flags == this.flags)
+ return this;
+ else
+ return new Wildcards(flags);
+ }
+
+ /**
+ * return a Wildcard object that is inverted to this wildcard object.
+ * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
+ * unmodified. </b>
+ * @return a modified object
+ */
+ public Wildcards inverted() {
+ return Wildcards.of(flags ^ OFWildcardFlags.OFPFW_ALL_SANITIZED);
+ }
+
+ public boolean isWildcarded(Flag flag) {
+ return flag.isFullyOn(flags);
+ }
+
+ /**
+ * return all wildcard flags that are fully wildcarded as an EnumSet. Do not
+ * modify. Note: some flags (like NW_SRC and NW_DST) that are partially
+ * wildcarded are not returned in this set.
+ *
+ * @return the EnumSet of wildcards
+ */
+ public EnumSet<Wildcards.Flag> getWildcardedFlags() {
+ EnumSet<Wildcards.Flag> res = EnumSet.noneOf(Wildcards.Flag.class);
+ for (Wildcards.Flag flag : Flag.values()) {
+ if (flag.isFullyOn(flags)) {
+ res.add(flag);
+ }
+ }
+ return res;
+ }
+
+ /** return the OpenFlow 'wire' integer representation of these wildcards */
+ public int getInt() {
+ return flags;
+ }
+
+ /**
+ * return the OpenFlow 'wire' integer representation of these wildcards.
+ * Sanitize nw_src and nw_dst to be max. 32 (values > 32 are technically
+ * possible, but don't make semantic sense)
+ */
+ public static int sanitizeInt(int flags) {
+ if (((flags & OFWildcardFlags.OFPFW_NW_SRC_MASK) >> OFWildcardFlags.OFPFW_NW_SRC_SHIFT) > 32) {
+ flags = (flags & ~OFWildcardFlags.OFPFW_NW_SRC_MASK) | OFWildcardFlags.OFPFW_NW_SRC_ALL;
+ }
+ if (((flags & OFWildcardFlags.OFPFW_NW_DST_MASK) >> OFWildcardFlags.OFPFW_NW_DST_SHIFT) > 32) {
+ flags = (flags & ~OFWildcardFlags.OFPFW_NW_DST_MASK) | OFWildcardFlags.OFPFW_NW_DST_ALL;
+ }
+ return flags;
+ }
+
+ /**
+ * is this a wildcard set that has all flags set + and full (/0) nw_src and
+ * nw_dst wildcarding ?
+ */
+ public boolean isFull() {
+ return flags == OFWildcardFlags.OFPFW_ALL || flags == OFWildcardFlags.OFPFW_ALL_SANITIZED;
+ }
+
+ /** is this a wildcard of an exact match */
+ public boolean isExact() {
+ return flags == 0;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + flags;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Wildcards other = (Wildcards) obj;
+ if (flags != other.flags)
+ return false;
+ return true;
+ }
+
+ private final static Joiner pipeJoiner = Joiner.on("|");
+
+ @Override
+ public String toString() {
+ List<String> res = new ArrayList<String>();
+ for (Wildcards.Flag flag : Flag.values()) {
+ if (flag.isFullyOn(flags)) {
+ res.add(flag.name().toLowerCase());
+ }
+ }
+
+ if (Flag.NW_SRC.isPartiallyOn(flags)) {
+ res.add("nw_src(/" + getNwSrcMask() + ")");
+ }
+
+ if (Flag.NW_DST.isPartiallyOn(flags)) {
+ res.add("nw_dst(/" + getNwDstMask() + ")");
+ }
+
+ return pipeJoiner.join(res);
+ }
+
+ private final static Joiner commaJoiner = Joiner.on(", ");
+
+ /** a Java expression that constructs 'this' wildcards set */
+ public String toJava() {
+ if(isFull()) {
+ return "Wildcards.FULL";
+ } else if (isExact()){
+ return "Wildcards.EXACT";
+ }
+
+ StringBuilder b = new StringBuilder();
+
+ EnumSet<Flag> myFlags = getWildcardedFlags();
+ if (myFlags.size() < 3) {
+ // default to start with empty
+ b.append("Wildcards.of("
+ + commaJoiner.join(prefix("Flag.", myFlags.iterator())) + ")");
+ } else {
+ // too many - start with full
+
+ EnumSet<Flag> invFlags = inverted().getWildcardedFlags();
+ b.append("Wildcards.ofMatches("
+ + commaJoiner.join(prefix("Flag.", invFlags.iterator())) + ")");
+ }
+ if (Flag.NW_SRC.isPartiallyOn(flags)) {
+ b.append(".setNwSrcMask(" + getNwSrcMask() + ")");
+ }
+ if (Flag.NW_DST.isPartiallyOn(flags)) {
+ b.append(".setNwDstMask(" + getNwDstMask() + ")");
+ }
+ return b.toString();
+ }
+
+ private Iterator<String> prefix(final String prefix, final Iterator<?> i) {
+ return new Iterator<String>() {
+
+ @Override
+ public boolean hasNext() {
+ return i.hasNext();
+ }
+
+ @Override
+ public String next() {
+ Object next = i.next();
+ return next == null ? null : prefix + next.toString();
+ }
+
+ @Override
+ public void remove() {
+ i.remove();
+ }
+ };
+ }
+
+
+}
\ No newline at end of file
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Writeable.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Writeable.java
new file mode 100644
index 0000000..31ae9ab
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Writeable.java
@@ -0,0 +1,7 @@
+package org.projectfloodlight.openflow.protocol;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface Writeable {
+ void writeTo(ChannelBuffer bb);
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/XidGenerator.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/XidGenerator.java
new file mode 100644
index 0000000..65976dc
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/XidGenerator.java
@@ -0,0 +1,5 @@
+package org.projectfloodlight.openflow.protocol;
+
+public interface XidGenerator {
+ int nextXid();
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/Match.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/Match.java
new file mode 100644
index 0000000..5e68de5
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/Match.java
@@ -0,0 +1,207 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+import org.projectfloodlight.openflow.protocol.OFObject;
+import org.projectfloodlight.openflow.types.Masked;
+import org.projectfloodlight.openflow.types.OFValueType;
+
+/**
+ * Generic interface for version-agnostic immutable Match structure.
+ * The Match structure is defined in the OpenFlow protocol, and it contains information on
+ * the fields to be matched in a specific flow record.
+ * This interface does not assume anything on the fields in the Match structure. If in
+ * some version, the match structure cannot handle a certain field, it may return <code>false</code>
+ * for <code>supports(...)</code> calls, and throw <code>UnsupportedOperationException</code> from all
+ * other methods in such cases.
+ * <br><br>
+ * On wildcards and masks:<br>
+ * This interface defines the following masking notations for fields:
+ * <ul>
+ * <li><b>Exact</b>: field is matched exactly against a single, fixed value (no mask, or mask is all ones).
+ * <li><b>Wildcarded</b>: field is not being matched. It is fully masked (mask=0) and any value of it
+ * will match the flow record having this match.
+ * <li><b>Partially masked</b>: field is matched using a specified mask which is neither 0 nor all ones. Mask can
+ * be either arbitrary or require some specific structure.
+ * </ul>
+ * Implementing classes may or may not support all types of these masking types. They may also support
+ * them in part. For example, OF1.0 supports exact match and (full) wildcarding for all fields, but it
+ * does only supports partial masking for IP source/destination fields, and this partial masking must be
+ * in the CIDR prefix format. Thus, OF1.0 implementation may throw <code>UnsupportedOperationException</code> if given
+ * in <code>setMaksed</code> an IP mask of, for example, 255.0.255.0, or if <code>setMasked</code> is called for any field
+ * which is not IP source/destination address.
+ * <br><br>
+ * On prerequisites:<br>
+ * From the OF1.1 spec, page 28, the OF1.0 spec failed to explicitly specify this, but it
+ * is the behavior of OF1.0 switches:
+ * "Protocol-specific fields within ofp_match will be ignored within a single table when
+ * the corresponding protocol is not specified in the match. The MPLS match fields will
+ * be ignored unless the Ethertype is specified as MPLS. Likewise, the IP header and
+ * transport header fields will be ignored unless the Ethertype is specified as either
+ * IPv4 or ARP. The tp_src and tp_dst fields will be ignored unless the network protocol
+ * specified is as TCP, UDP or SCTP. Fields that are ignored don�t need to be wildcarded
+ * and should be set to 0."
+ * <br><br>
+ * This interface uses generics to assure type safety in users code. However, implementing classes may have to suppress
+ * 'unchecked cast' warnings while making sure they correctly cast base on their implementation details.
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ */
+public interface Match extends OFObject {
+
+ /**
+ * Returns a value for the given field if:
+ * <ul>
+ * <li>Field is supported
+ * <li>Field is not fully wildcarded
+ * <li>Prerequisites are ok
+ * </ul>
+ * If one of the above conditions does not hold, returns null. Value is returned masked if partially wildcarded.
+ *
+ * @param field Match field to retrieve
+ * @return Value of match field (may be masked), or <code>null</code> if field is one of the conditions above does not hold.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns the masked value for the given field from this match, along with the mask itself.
+ * Prerequisite: field is partially masked.
+ * If prerequisite is not met, a <code>null</code> is returned.
+ *
+ * @param field Match field to retrieve.
+ * @return Masked value of match field or null if no mask is set.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns true if and only if this match object supports the given match field.
+ *
+ * @param field Match field
+ * @return true if field is supported, false otherwise.
+ */
+ public boolean supports(MatchField<?> field);
+
+ /**
+ * Returns true if and only if this match object supports partially bitmasking of the given field.
+ * (note: not all possible values of this bitmask have to be acceptable)
+ *
+ * @param field Match field.
+ * @return true if field can be partially masked, false otherwise.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean supportsMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns true if and only if this field is currently specified in the match with an exact value and
+ * no mask. I.e., the specified match will only select packets that match the exact value of getValue(field).
+ *
+ * @param field Match field.
+ * @return true if field has a specific exact value, false if not.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean isExact(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * True if and only if this field is currently logically unspecified in the match, i.e, the
+ * value returned by getValue(f) has no impact on whether a packet will be selected
+ * by the match or not.
+ *
+ * @param field Match field.
+ * @return true if field is fully wildcarded, false if not.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean isFullyWildcarded(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * True if and only if this field is currently partially specified in the match, i.e, the
+ * match will only select packets that match (p.value & getMask(field)) == getValue(field),
+ * and getMask(field) != 0.
+ *
+ * @param field Match field.
+ * @return true if field is partially masked, false if not.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean isPartiallyMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns a builder to build new instances of this type of match object.
+ * @return Match builder
+ */
+ public Builder createBuilder();
+
+ /**
+ * Builder interface for Match objects.
+ * Builder is used to create new Match objects and it creates the match according to the version it
+ * corresponds to. The builder uses the same notation of wildcards and masks, and can also throw
+ * <code>UnsupportedOperationException</code> if it is asked to create some matching that is not supported in
+ * the version it represents.
+ *
+ * While used, MatchBuilder may not be consistent in terms of field prerequisites. However, user must
+ * solve these before using the generated Match object as these prerequisites should be enforced in the
+ * getters.
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ */
+ interface Builder {
+ public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
+
+ public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
+
+ public boolean supports(MatchField<?> field);
+
+ public boolean supportsMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ public boolean isExact(MatchField<?> field) throws UnsupportedOperationException;
+
+ public boolean isFullyWildcarded(MatchField<?> field) throws UnsupportedOperationException;
+
+ public boolean isPartiallyMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * Sets a specific exact value for a field.
+ *
+ * @param field Match field to set.
+ * @param value Value of match field.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> Builder setExact(MatchField<F> field, F value) throws UnsupportedOperationException;
+
+ /**
+ * Sets a masked value for a field.
+ *
+ * @param field Match field to set.
+ * @param value Value of field.
+ * @param mask Mask value.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported.
+ */
+ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, F value, F mask) throws UnsupportedOperationException;
+
+ /**
+ * Sets a masked value for a field.
+ *
+ * @param field Match field to set.
+ * @param valueWithMask Compound Masked object contains the value and the mask.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported.
+ */
+ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, Masked<F> valueWithMask) throws UnsupportedOperationException;
+
+ /**
+ * Unsets any value given for the field and wildcards it so that it matches any value.
+ *
+ * @param field Match field to unset.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> Builder wildcard(MatchField<F> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns the match created by this builder.
+ *
+ * @return a Match object.
+ */
+ public Match build();
+ }
+}
\ No newline at end of file
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
new file mode 100644
index 0000000..333d25d
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
@@ -0,0 +1,156 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+import org.projectfloodlight.openflow.types.ArpOpcode;
+import org.projectfloodlight.openflow.types.EthType;
+import org.projectfloodlight.openflow.types.ICMPv4Code;
+import org.projectfloodlight.openflow.types.ICMPv4Type;
+import org.projectfloodlight.openflow.types.IPv4;
+import org.projectfloodlight.openflow.types.IPv6;
+import org.projectfloodlight.openflow.types.IPv6FlowLabel;
+import org.projectfloodlight.openflow.types.IpDscp;
+import org.projectfloodlight.openflow.types.IpEcn;
+import org.projectfloodlight.openflow.types.IpProtocol;
+import org.projectfloodlight.openflow.types.MacAddress;
+import org.projectfloodlight.openflow.types.OFMetadata;
+import org.projectfloodlight.openflow.types.OFPort;
+import org.projectfloodlight.openflow.types.OFValueType;
+import org.projectfloodlight.openflow.types.TransportPort;
+import org.projectfloodlight.openflow.types.VlanPcp;
+import org.projectfloodlight.openflow.types.VlanVid;
+
+@SuppressWarnings("unchecked")
+public class MatchField<F extends OFValueType<F>> {
+ private final String name;
+ public final MatchFields id;
+ private final Prerequisite<?>[] prerequisites;
+
+ private MatchField(final String name, final MatchFields id, Prerequisite<?>... prerequisites) {
+ this.name = name;
+ this.id = id;
+ this.prerequisites = prerequisites;
+ }
+
+ public final static MatchField<OFPort> IN_PORT =
+ new MatchField<OFPort>("in_port", MatchFields.IN_PORT);
+
+ public final static MatchField<OFPort> IN_PHY_PORT =
+ new MatchField<OFPort>("in_phy_port", MatchFields.IN_PHY_PORT,
+ new Prerequisite<OFPort>(MatchField.IN_PORT));
+
+ public final static MatchField<OFMetadata> METADATA =
+ new MatchField<OFMetadata>("metadata", MatchFields.METADATA);
+
+ public final static MatchField<MacAddress> ETH_DST =
+ new MatchField<MacAddress>("eth_dst", MatchFields.ETH_DST);
+
+ public final static MatchField<MacAddress> ETH_SRC =
+ new MatchField<MacAddress>("eth_src", MatchFields.ETH_SRC);
+
+ public final static MatchField<EthType> ETH_TYPE =
+ new MatchField<EthType>("eth_type", MatchFields.ETH_TYPE);
+
+ public final static MatchField<VlanVid> VLAN_VID =
+ new MatchField<VlanVid>("vlan_vid", MatchFields.VLAN_VID);
+
+ public final static MatchField<VlanPcp> VLAN_PCP =
+ new MatchField<VlanPcp>("vlan_pcp", MatchFields.VLAN_PCP,
+ new Prerequisite<VlanVid>(MatchField.VLAN_VID));
+
+ public final static MatchField<IpDscp> IP_DSCP =
+ new MatchField<IpDscp>("ip_dscp", MatchFields.IP_DSCP,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4, EthType.ETH_TYPE_IPv6));
+
+ public final static MatchField<IpEcn> IP_ECN =
+ new MatchField<IpEcn>("ip_dscp", MatchFields.IP_ECN,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4, EthType.ETH_TYPE_IPv6));
+
+ public final static MatchField<IpProtocol> IP_PROTO =
+ new MatchField<IpProtocol>("ip_proto", MatchFields.IP_PROTO,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4, EthType.ETH_TYPE_IPv6));
+
+ public final static MatchField<IPv4> IPV4_SRC =
+ new MatchField<IPv4>("ipv4_src", MatchFields.IPV4_SRC,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4));
+
+ public final static MatchField<IPv4> IPV4_DST =
+ new MatchField<IPv4>("ipv4_dst", MatchFields.IPV4_DST,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4));
+
+ public final static MatchField<TransportPort> TCP_SRC = new MatchField<TransportPort>(
+ "tcp_src", MatchFields.TCP_SRC,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP));
+
+ public final static MatchField<TransportPort> TCP_DST = new MatchField<TransportPort>(
+ "tcp_dst", MatchFields.TCP_DST,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP));
+
+ public final static MatchField<TransportPort> UDP_SRC = new MatchField<TransportPort>(
+ "udp_src", MatchFields.UDP_SRC,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_UDP));
+
+ public final static MatchField<TransportPort> UDP_DST = new MatchField<TransportPort>(
+ "udp_dst", MatchFields.UDP_DST,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_UDP));
+
+ public final static MatchField<TransportPort> SCTP_SRC = new MatchField<TransportPort>(
+ "sctp_src", MatchFields.SCTP_SRC,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_SCTP));
+
+ public final static MatchField<TransportPort> SCTP_DST = new MatchField<TransportPort>(
+ "sctp_dst", MatchFields.SCTP_DST,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_SCTP));
+
+ public final static MatchField<ICMPv4Type> ICMPV4_TYPE = new MatchField<ICMPv4Type>(
+ "icmpv4_src", MatchFields.ICMPV4_TYPE,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_ICMP));
+
+ public final static MatchField<ICMPv4Code> ICMPV4_CODE = new MatchField<ICMPv4Code>(
+ "icmpv4_dst", MatchFields.ICMPV4_CODE,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IP_PROTO_ICMP));
+
+ public final static MatchField<ArpOpcode> ARP_OP = new MatchField<ArpOpcode>(
+ "arp_op", MatchFields.ARP_OP,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+
+ public final static MatchField<IPv4> ARP_SPA =
+ new MatchField<IPv4>("arp_spa", MatchFields.ARP_SPA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+
+ public final static MatchField<IPv4> ARP_TPA =
+ new MatchField<IPv4>("arp_tpa", MatchFields.ARP_TPA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+
+ public final static MatchField<MacAddress> ARP_SHA =
+ new MatchField<MacAddress>("arp_sha", MatchFields.ARP_SHA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+
+ public final static MatchField<MacAddress> ARP_THA =
+ new MatchField<MacAddress>("arp_tha", MatchFields.ARP_THA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+
+ public final static MatchField<IPv6> IPV6_SRC =
+ new MatchField<IPv6>("ipv6_src", MatchFields.IPV6_SRC,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6));
+
+ public final static MatchField<IPv6> IPV6_DST =
+ new MatchField<IPv6>("ipv6_dst", MatchFields.IPV6_DST,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6));
+
+ public final static MatchField<IPv6FlowLabel> IPV6_FLABEL =
+ new MatchField<IPv6FlowLabel>("ipv6_flabel", MatchFields.IPV6_FLABEL,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6));
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean arePrerequisitesOK(Match match) {
+ for (Prerequisite<?> p : this.prerequisites) {
+ if (!p.isSatisfied(match)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java
new file mode 100644
index 0000000..2fc10ae
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java
@@ -0,0 +1,34 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+// MUST BE ORDERED BY THE ORDER OF OF SPEC!!!
+public enum MatchFields {
+ IN_PORT,
+ IN_PHY_PORT,
+ METADATA,
+ ETH_DST,
+ ETH_SRC,
+ ETH_TYPE,
+ VLAN_VID,
+ VLAN_PCP,
+ IP_DSCP,
+ IP_ECN,
+ IP_PROTO,
+ IPV4_SRC,
+ IPV4_DST,
+ TCP_SRC,
+ TCP_DST,
+ UDP_SRC,
+ UDP_DST,
+ SCTP_SRC,
+ SCTP_DST,
+ ICMPV4_TYPE,
+ ICMPV4_CODE,
+ ARP_OP,
+ ARP_SPA,
+ ARP_TPA,
+ ARP_SHA,
+ ARP_THA,
+ IPV6_SRC,
+ IPV6_DST,
+ IPV6_FLABEL,
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/Prerequisite.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/Prerequisite.java
new file mode 100644
index 0000000..4e667e7
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/Prerequisite.java
@@ -0,0 +1,44 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.projectfloodlight.openflow.types.OFValueType;
+
+public class Prerequisite<T extends OFValueType<T>> {
+ private final MatchField<T> field;
+ private final Set<OFValueType<T>> values;
+ private boolean any;
+
+ public Prerequisite(MatchField<T> field, OFValueType<T>... values) {
+ this.values = new HashSet<OFValueType<T>>();
+ this.field = field;
+ if (values == null || values.length == 0) {
+ this.any = true;
+ } else {
+ this.any = false;
+ for (OFValueType<T> value : values) {
+ this.values.add(value);
+ }
+ }
+ }
+
+ /**
+ * Returns true if this prerequisite is satisfied by the given match object.
+ *
+ * @param match Match object
+ * @return true iff prerequisite is satisfied.
+ */
+ public boolean isSatisfied(Match match) {
+ OFValueType<T> res = match.get(this.field);
+ if (res == null)
+ return false;
+ if (this.any)
+ return true;
+ if (this.values.contains(res)) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver10/ChannelUtilsVer10.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver10/ChannelUtilsVer10.java
new file mode 100644
index 0000000..7a42d20
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver10/ChannelUtilsVer10.java
@@ -0,0 +1,31 @@
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+import org.projectfloodlight.openflow.protocol.match.Match;
+import org.projectfloodlight.openflow.protocol.ver10.OFMatchV1Ver10;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQ;
+
+/**
+ * Collection of helper functions for reading and writing into ChannelBuffers
+ *
+ * @author capveg
+ */
+
+public class ChannelUtilsVer10 {
+ public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
+ return OFMatchV1Ver10.READER.readFrom(bb);
+ }
+
+ // TODO these need to be figured out / removed
+ public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static void writeOFBsnVportQInQ(ChannelBuffer bb,
+ OFBsnVportQInQ vport) {
+ throw new UnsupportedOperationException("not implemented");
+
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver11/ChannelUtilsVer11.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver11/ChannelUtilsVer11.java
new file mode 100644
index 0000000..735fe3b
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver11/ChannelUtilsVer11.java
@@ -0,0 +1,39 @@
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+import org.projectfloodlight.openflow.protocol.OFMatchBmap;
+import org.projectfloodlight.openflow.protocol.match.Match;
+import org.projectfloodlight.openflow.protocol.ver11.OFMatchV2Ver11;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQ;
+
+/**
+ * Collection of helper functions for reading and writing into ChannelBuffers
+ *
+ * @author capveg
+ */
+
+public class ChannelUtilsVer11 {
+ public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
+ return OFMatchV2Ver11.READER.readFrom(bb);
+ }
+
+ // TODO these need to be figured out / removed
+ public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static void writeOFBsnVportQInQ(ChannelBuffer bb,
+ OFBsnVportQInQ vport) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+
+ public static OFMatchBmap readOFMatchBmap(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static void writeOFMatchBmap(ChannelBuffer bb, OFMatchBmap match) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver12/ChannelUtilsVer12.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver12/ChannelUtilsVer12.java
new file mode 100644
index 0000000..756363d
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver12/ChannelUtilsVer12.java
@@ -0,0 +1,40 @@
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+import org.projectfloodlight.openflow.protocol.OFMatchBmap;
+import org.projectfloodlight.openflow.protocol.match.Match;
+import org.projectfloodlight.openflow.protocol.ver12.OFMatchV3Ver12;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQ;
+
+/**
+ * Collection of helper functions for reading and writing into ChannelBuffers
+ *
+ * @author capveg
+ */
+
+public class ChannelUtilsVer12 {
+ public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
+ return OFMatchV3Ver12.READER.readFrom(bb);
+ }
+
+ // TODO these need to be figured out / removed
+
+ public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static void writeOFBsnVportQInQ(ChannelBuffer bb,
+ OFBsnVportQInQ vport) {
+ throw new UnsupportedOperationException("not implemented");
+
+ }
+
+ public static OFMatchBmap readOFMatchBmap(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static void writeOFMatchBmap(ChannelBuffer bb, OFMatchBmap match) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver13/ChannelUtilsVer13.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver13/ChannelUtilsVer13.java
new file mode 100644
index 0000000..0be26ae
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver13/ChannelUtilsVer13.java
@@ -0,0 +1,39 @@
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+import org.projectfloodlight.openflow.protocol.OFMatchBmap;
+import org.projectfloodlight.openflow.protocol.match.Match;
+import org.projectfloodlight.openflow.protocol.ver13.OFMatchV3Ver13;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQ;
+
+/**
+ * Collection of helper functions for reading and writing into ChannelBuffers
+ *
+ * @author capveg
+ */
+
+public class ChannelUtilsVer13 {
+ public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
+ return OFMatchV3Ver13.READER.readFrom(bb);
+ }
+
+ // TODO these need to be figured out / removed
+
+ public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static void writeOFBsnVportQInQ(ChannelBuffer bb,
+ OFBsnVportQInQ vport) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static OFMatchBmap readOFMatchBmap(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public static void writeOFMatchBmap(ChannelBuffer bb, OFMatchBmap match) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+}