java_gen: work in progress commit of java generator
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFAbstractMessage.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFAbstractMessage.java
new file mode 100644
index 0000000..bc2218f
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFAbstractMessage.java
@@ -0,0 +1,83 @@
+/* Copyright 2013, Big Switch Networks, Inc.
+ *
+ * LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+ * the following special exception:
+ *
+ * LOXI Exception
+ *
+ * As a special exception to the terms of the EPL, you may distribute libraries
+ * generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+ * that copyright and licensing notices generated by LoxiGen are not altered or removed
+ * from the LoxiGen Libraries and the notice provided below is (i) included in
+ * the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+ * documentation for the LoxiGen Libraries, if distributed in binary form.
+ *
+ * Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+ *
+ * You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+ * a copy of the EPL at:
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * 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
+ * EPL for the specific language governing permissions and limitations
+ * under the EPL.
+ */
+package org.openflow.protocol;
+
+/**
+ * The base interface for all OpenFlow message objects
+ */
+
+import org.openflow.types.OFType;
+
+abstract public class OFAbstractMessage implements OFObject {
+ private final OFVersion version;
+ private final OFType type;
+ private int xid;
+
+ public static int MINIMUM_SIZE = 8;
+
+ public OFAbstractMessage(final OFVersion version, final OFType type) {
+ this.version = version;
+ this.type = type;
+ }
+
+ /**
+ * Return the wire format version of this message, e.g., 0x01
+ */
+ OFVersion getVersion() {
+ return version;
+ }
+
+ /**
+ * @return the transction ID for this message
+ */
+ int getXid() {
+ return xid;
+ }
+
+ /**
+ * @param newXid
+ * Set this transaction ID for this message
+ */
+ void setXid(final int xid) {
+ this.xid = xid;
+ }
+
+ /**
+ * The type that is returned here is agnostic to the underlying wire format
+ *
+ * @return the type of OpenFlow message.
+ */
+ OFType getType() {
+ return type;
+ }
+
+ @Override
+ public int getLength() {
+ return MINIMUM_SIZE;
+ }
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessage.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessage.java
new file mode 100644
index 0000000..4f31741
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessage.java
@@ -0,0 +1,13 @@
+package org.openflow.protocol;
+
+import org.openflow.types.OFType;
+
+public interface OFMessage {
+ int getXid();
+
+ boolean isXidSet();
+
+ OFType getType();
+
+ OFVersion getVersion();
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessageReader.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessageReader.java
new file mode 100644
index 0000000..24c3314
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessageReader.java
@@ -0,0 +1,8 @@
+package org.openflow.protocol;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+
+public interface OFMessageReader<T extends OFMessage> {
+ T readFrom(ChannelBuffer bb) throws OFParseError;
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObject.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObject.java
new file mode 100644
index 0000000..21a4607
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObject.java
@@ -0,0 +1,35 @@
+package org.openflow.protocol;
+
+/**
+ * Base interface of all OpenFlow objects (e.g., messages, actions, stats, etc.)
+ *
+ * All objects have a length and can be read and written from a buffer.
+ * When writing, the length field is dynamically updated, so it need not be
+ * managed manually. However, you can override the auto calculated length with
+ * overrideLength() call, if, for example, you want to intentionally create
+ * malformed packets, for example, for negative testing.
+ */
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+import org.openflow.exceptions.OFShortWrite;
+
+public interface OFObject {
+ /**
+ * Return a number equal or greater than zero (and currently in OF less than
+ * 65536)
+ *
+ * @return the number of bytes this object will represent on the wire
+ */
+ public int getLength();
+
+ /**
+ * Automatically calculate any lengths and write an openflow object into the
+ * byte buffer.
+ *
+ * @param bb
+ * A valid byte buffer with sufficient capacity to hold this
+ * object/
+ */
+ public void writeTo(ChannelBuffer bb) throws OFParseError, OFShortWrite;
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObjectFactory.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObjectFactory.java
new file mode 100644
index 0000000..86cafb1
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObjectFactory.java
@@ -0,0 +1,7 @@
+package org.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/openflow/protocol/OFVersion.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFVersion.java
new file mode 100644
index 0000000..afc0393
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFVersion.java
@@ -0,0 +1,16 @@
+package org.openflow.protocol;
+
+public enum OFVersion {
+ OF_10(1), OF_11(2), OF_12(3), OF_13(4);
+
+ private 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/openflow/protocol/actions/OFAction.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/actions/OFAction.java
new file mode 100644
index 0000000..f01f8fe
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/actions/OFAction.java
@@ -0,0 +1,7 @@
+package org.openflow.protocol.actions;
+
+import org.openflow.protocol.OFObject;
+
+public interface OFAction extends OFObject {
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/instructions/OFInstruction.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/instructions/OFInstruction.java
new file mode 100644
index 0000000..8af305c
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/instructions/OFInstruction.java
@@ -0,0 +1,7 @@
+package org.openflow.protocol.instructions;
+
+import org.openflow.protocol.OFObject;
+
+public interface OFInstruction extends OFObject {
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Match.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Match.java
new file mode 100644
index 0000000..5c1e7b5
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Match.java
@@ -0,0 +1,21 @@
+package org.openflow.protocol.match;
+
+import org.openflow.protocol.OFObject;
+
+public interface Match extends OFObject {
+ public <F> F get(MatchField<F, ?> match);
+
+ public <M> M getMasked(MatchField<?, M> match);
+
+ public boolean supports(MatchField<?, ?> field);
+
+ public boolean supportsMasked(MatchField<?, ?> field);
+
+ public boolean isExact(MatchField<?, ?> field);
+
+ public boolean isFullyWildcarded(MatchField<?, ?> field);
+
+ public boolean isPartiallyMasked(MatchField<?, ?> field);
+
+ public MatchBuilder getBuilder();
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilder.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilder.java
new file mode 100644
index 0000000..7a5e57c
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilder.java
@@ -0,0 +1,9 @@
+package org.openflow.protocol.match;
+
+public interface MatchBuilder extends Match {
+ public <F> MatchBuilder set(MatchField<F, ?> match, F value);
+
+ public <M> void setMasked(MatchField<?, M> match, M value);
+
+ public Match getMatch();
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilderVer10.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilderVer10.java
new file mode 100644
index 0000000..19ced8f
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilderVer10.java
@@ -0,0 +1,177 @@
+package org.openflow.protocol.match;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+import org.openflow.exceptions.OFShortWrite;
+import org.openflow.protocol.types.IpDscp;
+import org.openflow.types.EthType;
+import org.openflow.types.IPv4;
+import org.openflow.types.IpProtocol;
+import org.openflow.types.MacAddress;
+import org.openflow.types.OFPort;
+import org.openflow.types.U16;
+import org.openflow.types.VlanPcp;
+import org.openflow.types.VlanVid;
+
+public class MatchBuilderVer10 implements MatchBuilder {
+
+ interface BuilderParamHandler<T> {
+ public T get(MatchBuilderVer10 builder);
+
+ public void set(MatchBuilderVer10 builder, T value);
+ }
+
+ // public static Map<MatchField<?,?>, BuilderParamHandler<?>>
+ // handlerMap = new HashMap();
+ static BuilderParamHandler<?>[] handlers = new BuilderParamHandler<?>[2];
+
+ static {
+ handlers[MatchField.IN_PORT.id] = new BuilderParamHandler<OFPort>() {
+ @Override
+ public void set(final MatchBuilderVer10 builder, final OFPort value) {
+ builder.inputPort = value;
+ }
+
+ @Override
+ public OFPort get(final MatchBuilderVer10 builder) {
+ return builder.inputPort;
+ }
+ };
+
+ handlers[MatchField.ETH_SRC.id] = new BuilderParamHandler<MacAddress>() {
+ @Override
+ public void set(final MatchBuilderVer10 builder, final MacAddress value) {
+ builder.dataLayerSource = value;
+ }
+
+ @Override
+ public MacAddress get(final MatchBuilderVer10 builder) {
+ return builder.dataLayerSource;
+ }
+ };
+ }
+
+ protected int wildcards;
+ protected OFPort inputPort;
+ protected MacAddress dataLayerSource;
+ protected MacAddress dataLayerDestination;
+ protected VlanVid dataLayerVirtualLan;
+ protected VlanPcp dataLayerVirtualLanPriorityCodePoint;
+ protected EthType dataLayerType;
+ protected IpDscp ipDscp;
+ protected IpProtocol networkProtocol;
+ protected IPv4 networkSource;
+ protected IPv4 networkDestination;
+ protected U16 transportSource;
+ protected U16 transportDestination;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <F> F get(final MatchField<F, ?> match) {
+ switch (match.id) {
+ case 0:
+ return (F) inputPort;
+ case 1:
+ return (F) dataLayerSource;
+ default:
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <F> MatchBuilder set(final MatchField<F, ?> match, final F value) {
+ switch (match.id) {
+ case 0:
+ inputPort = (OFPort) value;
+ break;
+ case 1:
+ dataLayerSource = (MacAddress) value;
+ break;
+ }
+ return this;
+ }
+
+ public OFPort getInputPort() {
+ return inputPort;
+ }
+
+ public void setInputPort(final OFPort inputPort) {
+ this.inputPort = inputPort;
+ }
+
+ public MacAddress getDataLayerSource() {
+ return dataLayerSource;
+ }
+
+ public void setDataLayerSource(final MacAddress dataLayerSource) {
+ this.dataLayerSource = dataLayerSource;
+ }
+
+ @Override
+ public <M> M getMasked(final MatchField<?, M> match) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean supports(final MatchField<?, ?> field) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsMasked(final MatchField<?, ?> field) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isExact(final MatchField<?, ?> field) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isFullyWildcarded(final MatchField<?, ?> field) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isPartiallyMasked(final MatchField<?, ?> field) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public MatchBuilder getBuilder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void writeTo(final ChannelBuffer bb) throws OFParseError, OFShortWrite {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public <M> void setMasked(final MatchField<?, M> match, final M value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Match getMatch() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchField.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchField.java
new file mode 100644
index 0000000..b6e8317
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchField.java
@@ -0,0 +1,106 @@
+package org.openflow.protocol.match;
+
+import org.openflow.types.EthType;
+import org.openflow.types.IPv4;
+import org.openflow.types.IPv4WithMask;
+import org.openflow.types.IPv6;
+import org.openflow.types.IPv6WithMask;
+import org.openflow.types.IpProtocol;
+import org.openflow.types.MacAddress;
+import org.openflow.types.MacAddressWithMask;
+import org.openflow.types.OFPort;
+import org.openflow.types.U16;
+import org.openflow.types.U8;
+import org.openflow.types.VlanPcp;
+import org.openflow.types.VlanVid;
+import org.openflow.types.VlanVidWithMask.VlanVidWithMask;
+
+public class MatchField<F, M> {
+ private final String name;
+ public final int id;
+
+ public MatchField(final String name) {
+ this.name = name;
+ this.id = -1;
+ }
+
+ public MatchField(final String name, final int id) {
+ this.name = name;
+ this.id = id;
+ }
+
+ public final static MatchField<OFPort, NoMatch> IN_PORT =
+ new MatchField<OFPort, NoMatch>("in_port", 0);
+ public final static MatchField<OFPort, NoMatch> IN_PHY_PORT =
+ new MatchField<OFPort, NoMatch>("in_phy_port");
+ public final static MatchField<OFPort, NoMatch> METADATA =
+ new MatchField<OFPort, NoMatch>("metadata");
+
+ public final static MatchField<MacAddress, MacAddressWithMask> ETH_DST =
+ new MatchField<MacAddress, MacAddressWithMask>("eth_dst");
+ public final static MatchField<MacAddress, MacAddressWithMask> ETH_SRC =
+ new MatchField<MacAddress, MacAddressWithMask>("eth_src", 1);
+
+ public final static MatchField<EthType, NoMatch> ETH_TYPE =
+ new MatchField<EthType, NoMatch>("eth_type");
+ public final static MatchField<VlanVid, VlanVidWithMask> VLAN_VID =
+ new MatchField<VlanVid, VlanVidWithMask>("vlan_vid");
+ public final static MatchField<VlanPcp, NoMatch> VLAN_PCP =
+ new MatchField<VlanPcp, NoMatch>("vlan_pcp");
+
+ public final static MatchField<NoMatch, NoMatch> IP_DSCP =
+ new MatchField<NoMatch, NoMatch>("ip_dscp");
+ public final static MatchField<NoMatch, NoMatch> IP_ECN =
+ new MatchField<NoMatch, NoMatch>("ip_dscp");
+ public final static MatchField<IpProtocol, NoMatch> IP_PROTO =
+ new MatchField<IpProtocol, NoMatch>("ip_proto");
+
+ public final static MatchField<IPv4, IPv4WithMask> IPV4_SRC =
+ new MatchField<IPv4, IPv4WithMask>("ipv4_src");
+ public final static MatchField<IPv4, IPv4WithMask> IPV4_DST =
+ new MatchField<IPv4, IPv4WithMask>("ipv4_dst");
+
+ public final static MatchField<U16, NoMatch> TCP_SRC = new MatchField<U16, NoMatch>(
+ "tcp_src");
+ public final static MatchField<U16, NoMatch> TCP_DST = new MatchField<U16, NoMatch>(
+ "tcp_dst");
+
+ public final static MatchField<U16, NoMatch> UDP_SRC = new MatchField<U16, NoMatch>(
+ "udp_src");
+ public final static MatchField<U16, NoMatch> UDP_DST = new MatchField<U16, NoMatch>(
+ "udp_dst");
+
+ public final static MatchField<U16, NoMatch> SCTP_SRC = new MatchField<U16, NoMatch>(
+ "sctp_src");
+ public final static MatchField<U16, NoMatch> SCTP_DST = new MatchField<U16, NoMatch>(
+ "sctp_dst");
+
+ public final static MatchField<U8, NoMatch> ICMPV4_TYPE = new MatchField<U8, NoMatch>(
+ "icmpv4_src");
+ public final static MatchField<U8, NoMatch> ICMPV4_CODE = new MatchField<U8, NoMatch>(
+ "icmpv4_dst");
+
+ public final static MatchField<U16, NoMatch> ARP_OP = new MatchField<U16, NoMatch>(
+ "arp_op");
+ public final static MatchField<IPv4, IPv4WithMask> ARP_SPA =
+ new MatchField<IPv4, IPv4WithMask>("arp_spa");
+ public final static MatchField<IPv4, IPv4WithMask> ARP_TPA =
+ new MatchField<IPv4, IPv4WithMask>("arp_tpa");
+ public final static MatchField<MacAddress, MacAddressWithMask> ARP_SHA =
+ new MatchField<MacAddress, MacAddressWithMask>("arp_sha");
+ public final static MatchField<MacAddress, MacAddressWithMask> ARP_THA =
+ new MatchField<MacAddress, MacAddressWithMask>("arp_tha");
+
+ public final static MatchField<IPv6, IPv6WithMask> IPV6_SRC =
+ new MatchField<IPv6, IPv6WithMask>("ipv6_src");
+ public final static MatchField<IPv6, IPv6WithMask> IPV6_DST =
+ new MatchField<IPv6, IPv6WithMask>("ipv6_dst");
+
+ public final static MatchField<U8, IPv6WithMask> IPV6_FLABEL =
+ new MatchField<U8, IPv6WithMask>("ipv6_flabel");
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/NoMatch.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/NoMatch.java
new file mode 100644
index 0000000..b314a59
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/NoMatch.java
@@ -0,0 +1,5 @@
+package org.openflow.protocol.match;
+
+public class NoMatch {
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/types/IpDscp.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/types/IpDscp.java
new file mode 100644
index 0000000..dcc242a
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/types/IpDscp.java
@@ -0,0 +1,5 @@
+package org.openflow.protocol.types;
+
+public class IpDscp {
+
+}