IPAddress and IPAddressWithMask updates and fixes
* Provide asCidrPrefixMask to determine if an IPAddress represents a valid CIDR netmask
* cidr prefix length computation was broken:
+ 0 not detected as valid CIDR
+ BigInteger is signed. Grrr
* Add more unit test cases
* Test asCidrPrefixMask
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
index 7c50aed..ed8a11b 100644
--- 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
@@ -4,6 +4,29 @@
public abstract IPVersion getIpVersion();
+ /**
+ * Checks if this IPAddress represents a valid CIDR style netmask, i.e.,
+ * it has a set of leading "1" bits followed by only "0" bits
+ * @return true if this represents a valid CIDR style netmask, false
+ * otherwise
+ */
+ public boolean isCidrMask() {
+ return asCidrMaskLength() != -1;
+ }
+
+ /**
+ * If this IPAddress represents a valid CIDR style netmask (see
+ * isCidrMask()) returns the length of the prefix (the number of "1" bits).
+ * @return length of CIDR mask or -1 if this is not a CIDR netmask
+ */
+ public abstract int asCidrMaskLength();
+
+ @Override
+ public abstract boolean equals(Object other);
+
+ @Override
+ public abstract int hashCode();
+
public static IPAddress<?> of(String ip) {
if (ip.indexOf('.') != -1)
return IPv4Address.of(ip);