1. Removed type serializers, added (write|read)[0-9]*Byte[s]?(ChannelBuffer) method to value types instead.
2. Updated Masked fields for IPv4, IPv6 with specific string methods.
3. Added value types for other fields from the spec
4. Updated unit tests accordingly
5. Changed java_type.py to support multiple read/write operations per type, per OF version.
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java
index c05a7e3..78b8dd2 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java
@@ -1,7 +1,7 @@
package org.openflow.types;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.exceptions.OFParseError;
+
/**
@@ -56,61 +56,6 @@
}
return IPv4.of(raw);
}
-
- public static OFValueType ofPossiblyMasked(final String string) {
- int start = 0;
- int shift = 24;
- int slashPos;
-
- String ip = string;
- int maskBits = 0;
- if ((slashPos = string.indexOf('/')) != -1) {
- ip = string.substring(0, slashPos);
- try {
- String suffix = string.substring(slashPos + 1);
- if (suffix.length() == 0)
- throw new IllegalArgumentException("IP Address not well formed: " + string);
- maskBits = 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);
- }
- }
-
- int raw = 0;
- while (shift >= 0) {
- int end = ip.indexOf('.', start);
- if (end == start || !((shift > 0) ^ (end < 0)))
- throw new IllegalArgumentException("IP Address not well formed: " + string);
-
- String substr =
- end > 0 ? ip.substring(start, end) : ip.substring(start);
- int val;
- try {
- val = Integer.parseInt(substr);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("IP Address not well formed: " + string);
- }
- if (val < 0 || val > 255)
- throw new IllegalArgumentException("IP Address not well formed: " + string);
-
- raw |= val << shift;
-
- shift -= 8;
- start = end + 1;
- }
-
- if (maskBits == 0) {
- // No mask
- return IPv4.of(raw);
- } else {
- // With mask
- int mask = (-1) << (32 - maskBits);
- return Masked.<IPv4>of(IPv4.of(raw), IPv4.of(mask));
- }
- }
public int getInt() {
return rawValue;
@@ -170,22 +115,12 @@
return true;
}
- public static final Serializer<IPv4> SERIALIZER_V10 = new SerializerV10();
- public static final Serializer<IPv4> SERIALIZER_V11 = SERIALIZER_V10;
- public static final Serializer<IPv4> SERIALIZER_V12 = SERIALIZER_V10;
- public static final Serializer<IPv4> SERIALIZER_V13 = SERIALIZER_V10;
-
- private static class SerializerV10 implements OFValueType.Serializer<IPv4> {
-
- @Override
- public void writeTo(IPv4 value, ChannelBuffer c) {
- c.writeInt(value.rawValue);
- }
-
- @Override
- public IPv4 readFrom(ChannelBuffer c) throws OFParseError {
- return IPv4.of(c.readInt());
- }
-
+ public void write4Bytes(ChannelBuffer c) {
+ c.writeInt(rawValue);
}
+
+ public static IPv4 read4Bytes(ChannelBuffer c) {
+ return IPv4.of(c.readInt());
+ }
+
}