Merge into master from pull request #304:
modified java_gen to support list of IPv4 and IPv6 addresses (https://github.com/floodlight/loxigen/pull/304)
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index 12d6260..abd9e5b 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -360,10 +360,20 @@
.op(read="IPv4Address.read4Bytes(bb)", \
write="$name.write4Bytes(bb)",
default='IPv4Address.NONE')
+ipv4_list = JType('List<IPv4Address>') \
+ .op(read='ChannelUtils.readList(bb, $length, IPv4Address.READER)',
+ write='ChannelUtils.writeList(bb, $name)',
+ default='ImmutableList.<IPv4Address>of()',
+ funnel="FunnelUtils.putList($name, sink)")
ipv6 = JType("IPv6Address") \
.op(read="IPv6Address.read16Bytes(bb)", \
write="$name.write16Bytes(bb)",
default='IPv6Address.NONE')
+ipv6_list = JType('List<IPv46ddress>') \
+ .op(read='ChannelUtils.readList(bb, $length, IPv6Address.READER)',
+ write='ChannelUtils.writeList(bb, $name)',
+ default='ImmutableList.<IPv6Address>of()',
+ funnel="FunnelUtils.putList($name, sink)")
packetin_reason = gen_enum_jtype("OFPacketInReason")
transport_port = JType("TransportPort")\
.op(read="TransportPort.read2Bytes(bb)",
@@ -531,6 +541,8 @@
'list(of_uint32_t)' : u32_list,
'list(of_uint8_t)' : u8_list,
'list(of_oxm_t)' : oxm_list,
+ 'list(of_ipv4_t)' : ipv4_list,
+ 'list(of_ipv6_t)' : ipv6_list,
'of_octets_t' : octets,
'of_match_t': of_match,
'of_fm_cmd_t': flow_mod_cmd,
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
index 3a1b15e..eb37a20 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
@@ -12,14 +12,16 @@
import com.google.common.hash.PrimitiveSink;
import com.google.common.primitives.UnsignedInts;
-
+import org.projectfloodlight.openflow.protocol.Writeable;
+import org.projectfloodlight.openflow.protocol.OFMessageReader;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
/**
* Wrapper around an IPv4Address address
*
* @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
*/
-public class IPv4Address extends IPAddress<IPv4Address> {
+public class IPv4Address extends IPAddress<IPv4Address> implements Writeable {
static final int LENGTH = 4;
private final int rawValue;
@@ -38,6 +40,15 @@
this.rawValue = rawValue;
}
+ public final static Reader READER = new Reader();
+
+ private static class Reader implements OFMessageReader<IPv4Address> {
+ @Override
+ public IPv4Address readFrom(ChannelBuffer bb) throws OFParseError {
+ return new IPv4Address(bb.readInt());
+ }
+ }
+
@Override
public IPVersion getIpVersion() {
return IPVersion.IPv4;
@@ -345,4 +356,8 @@
sink.putInt(rawValue);
}
+ @Override
+ public void writeTo(ChannelBuffer bb) {
+ bb.writeInt(rawValue);
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
index 471d0fb..a787ca9 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
@@ -8,19 +8,22 @@
import javax.annotation.Nonnull;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.projectfloodlight.openflow.exceptions.OFParseError;
import com.google.common.base.Preconditions;
import com.google.common.hash.PrimitiveSink;
import com.google.common.primitives.Longs;
+import org.projectfloodlight.openflow.protocol.Writeable;
+import org.projectfloodlight.openflow.protocol.OFMessageReader;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+
/**
* IPv6 address object. Instance controlled, immutable. Internal representation:
* two 64 bit longs (not that you'd have to know).
*
* @author Andreas Wundsam <andreas.wundsam@teleteach.de>
*/
-public class IPv6Address extends IPAddress<IPv6Address> {
+public class IPv6Address extends IPAddress<IPv6Address> implements Writeable {
static final int LENGTH = 16;
private final long raw1;
private final long raw2;
@@ -43,6 +46,15 @@
this.raw2 = raw2;
}
+ public final static Reader READER = new Reader();
+
+ private static class Reader implements OFMessageReader<IPv6Address> {
+ @Override
+ public IPv6Address readFrom(ChannelBuffer bb) throws OFParseError {
+ return new IPv6Address(bb.readLong(), bb.readLong());
+ }
+ }
+
@Override
public IPVersion getIpVersion() {
return IPVersion.IPv6;
@@ -538,4 +550,10 @@
sink.putLong(raw1);
sink.putLong(raw2);
}
+
+ @Override
+ public void writeTo(ChannelBuffer bb) {
+ bb.writeLong(raw1);
+ bb.writeLong(raw2);
+ }
}