Merge branch 'master' of github.com:floodlight/loxigen

Conflicts:
	java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/Prerequisite.java
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
index 96cf8e9..03d5e79 100644
--- 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
@@ -10,7 +10,8 @@
     private final Set<OFValueType<T>> values;
     private boolean any;
 
-    public Prerequisite(MatchField<T> field, @SuppressWarnings("unchecked") OFValueType<T>... values) {
+    @SafeVarargs
+    public Prerequisite(MatchField<T> field, OFValueType<T>... values) {
         this.values = new HashSet<OFValueType<T>>();
         this.field = field;
         if (values == null || values.length == 0) {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
new file mode 100644
index 0000000..761c433
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
@@ -0,0 +1,21 @@
+package org.projectfloodlight.openflow.types;
+
+public abstract class IPAddress<F extends IPAddress<F>> implements OFValueType<F> {
+
+    public enum IpVersion {
+        IPv4,
+        IPv6
+    }
+
+    public abstract IpVersion getIpVersion();
+
+    public static IPAddress<?> of(String ip) {
+        if (ip.indexOf('.') != -1)
+            return IPv4Address.of(ip);
+        else if (ip.indexOf(':') != -1)
+            return IPv6Address.of(ip);
+        else
+            throw new IllegalArgumentException("IP Address not well formed: " + ip);
+    }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
new file mode 100644
index 0000000..fc4fa7d
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
@@ -0,0 +1,22 @@
+package org.projectfloodlight.openflow.types;
+
+import org.projectfloodlight.openflow.types.IPAddress.IpVersion;
+
+public abstract class IPAddressWithMask<F extends IPAddress<F>> extends Masked<F> {
+
+    protected IPAddressWithMask(F value, F mask) {
+        super(value, mask);
+    }
+
+    public abstract IpVersion getIpVersion();
+
+    public static IPAddressWithMask<?> of(String ip) {
+        if (ip.indexOf('.') != -1)
+            return IPv4AddressWithMask.of(ip);
+        else if (ip.indexOf(':') != -1)
+            return IPv6AddressWithMask.of(ip);
+        else
+            throw new IllegalArgumentException("IP Address not well formed: " + ip);
+    }
+
+}
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 0a8994a..95cfdca 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
@@ -9,7 +9,7 @@
  *
  * @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
  */
-public class IPv4Address implements OFValueType<IPv4Address> {
+public class IPv4Address extends IPAddress<IPv4Address> {
     static final int LENGTH = 4;
     private final int rawValue;
 
@@ -23,6 +23,11 @@
         this.rawValue = rawValue;
     }
 
+    @Override
+    public IpVersion getIpVersion() {
+        return IpVersion.IPv4;
+    }
+
     public static IPv4Address of(final byte[] address) {
         if (address.length != LENGTH) {
             throw new IllegalArgumentException(
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
index 45f10d1..63dba38 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
@@ -1,6 +1,8 @@
 package org.projectfloodlight.openflow.types;
 
-public class IPv4AddressWithMask extends Masked<IPv4Address> {
+import org.projectfloodlight.openflow.types.IPAddress.IpVersion;
+
+public class IPv4AddressWithMask extends IPAddressWithMask<IPv4Address> {
     public final static IPv4AddressWithMask NONE = of(IPv4Address.NONE, IPv4Address.NONE);
 
     private IPv4AddressWithMask(int rawValue, int rawMask) {
@@ -11,6 +13,11 @@
         super(value, mask);
     }
 
+    @Override
+    public IpVersion getIpVersion() {
+        return IpVersion.IPv4;
+    }
+
     public static IPv4AddressWithMask of(int rawValue, int rawMask) {
         return new IPv4AddressWithMask(rawValue, rawMask);
     }
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 8afdaba..1239b74 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
@@ -11,7 +11,7 @@
  *
  * @author Andreas Wundsam <andreas.wundsam@teleteach.de>
  */
-public class IPv6Address implements OFValueType<IPv6Address> {
+public class IPv6Address extends IPAddress<IPv6Address> {
     static final int LENGTH = 16;
     private final long raw1;
     private final long raw2;
@@ -28,6 +28,11 @@
         this.raw2 = raw2;
     }
 
+    @Override
+    public IpVersion getIpVersion() {
+        return IpVersion.IPv6;
+    }
+
     public static IPv6Address of(final byte[] address) {
         if (address.length != LENGTH) {
             throw new IllegalArgumentException(
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
index dcaa0b6..f918d1c 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
@@ -3,13 +3,20 @@
 import java.math.BigInteger;
 import java.util.Arrays;
 
-public class IPv6AddressWithMask extends Masked<IPv6Address> {
+import org.projectfloodlight.openflow.types.IPAddress.IpVersion;
+
+public class IPv6AddressWithMask extends IPAddressWithMask<IPv6Address> {
     public final static IPv6AddressWithMask NONE = of(IPv6Address.NONE, IPv6Address.NONE);
 
     private IPv6AddressWithMask(IPv6Address value, IPv6Address mask) {
         super(value, mask);
     }
 
+    @Override
+    public IpVersion getIpVersion() {
+        return IpVersion.IPv6;
+    }
+
     public static IPv6AddressWithMask of(IPv6Address value, IPv6Address mask) {
         return new IPv6AddressWithMask(value, mask);
     }