Cleanup and rearrangements in Match structure and fields.
1. Added full documentation for the Match interface
2. Added Builder into Match interface and removed the separate class
3. Added ability to declare field prerequisites in the MatchField class and then check that they are
met using a given Match object
4. Fixed some small issues in value types and added a value type for Metadata
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java
index c24c4fd..0a1a6d3 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java
@@ -36,7 +36,7 @@
return res.toString();
}
- public static OFValueType<?> ofPossiblyMasked(final String string) {
+ public static IPv4WithMask of(final String string) {
int slashPos;
String ip = string;
int maskBits = 0;
@@ -72,7 +72,7 @@
return IPv4WithMask.of(ipv4, maskAddress);
} else if (maskBits == 0) {
// No mask
- return ipv4;
+ return IPv4WithMask.of(ipv4, IPv4.of(0xFFFFFFFF));
} else {
// With mask
int mask = (-1) << (32 - maskBits);
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java
index 72319e3..453507a 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java
@@ -31,7 +31,7 @@
return res.toString();
}
- public static OFValueType<?> ofPossiblyMasked(final String string) {
+ public static IPv6WithMask of(final String string) {
int slashPos;
String ip = string;
int maskBits = 0;
@@ -67,7 +67,7 @@
return IPv6WithMask.of(ipv6, maskAddress);
} else if (maskBits == 0) {
// No mask
- return ipv6;
+ return IPv6WithMask.of(ipv6, IPv6.of(0xFFFFFFFFFFFFFFFFl, 0xFFFFFFFFFFFFFFFFl));
} else {
// With mask
BigInteger mask = BigInteger.ONE.negate().shiftLeft(128 - maskBits);
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/OFMetadata.java b/java_gen/pre-written/src/main/java/org/openflow/types/OFMetadata.java
new file mode 100644
index 0000000..83d02da
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/OFMetadata.java
@@ -0,0 +1,34 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public class OFMetadata extends U64 implements OFValueType<OFMetadata> {
+
+ private static int LENGTH = 8;
+
+ protected OFMetadata(long raw) {
+ super(raw);
+ }
+
+ public static OFMetadata of(long raw) {
+ return new OFMetadata(raw);
+ }
+
+ public static OFMetadata read8Bytes(ChannelBuffer cb) {
+ return OFMetadata.of(cb.readLong());
+ }
+
+ public void write8Bytes(ChannelBuffer cb) {
+ cb.writeLong(super.getValue());
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public OFMetadata applyMask(OFMetadata mask) {
+ return OFMetadata.of(this.getValue() & mask.getValue());
+ }
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/U64.java b/java_gen/pre-written/src/main/java/org/openflow/types/U64.java
index 750398f..7871445 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/U64.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/U64.java
@@ -24,7 +24,7 @@
private final long raw;
- private U64(final long raw) {
+ protected U64(final long raw) {
this.raw = raw;
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java b/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java
index ca2c3c2..e36a5dd 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java
@@ -70,7 +70,7 @@
c.writeShort(this.vid);
}
- public VlanVid read2Bytes(ChannelBuffer c) throws OFParseError {
+ public static VlanVid read2Bytes(ChannelBuffer c) throws OFParseError {
return VlanVid.of(c.readShort());
}