fixing loxi output
upgrade to 0.3.8
agrregate pom for of-lib
Change-Id: Ie75d75b708c30934bbca235e68c50de656d84ad4
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
index 7259c7f..ee34923 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
@@ -1,7 +1,6 @@
package org.projectfloodlight.openflow.types;
-import java.math.BigInteger;
-import java.util.Arrays;
+import com.google.common.base.Preconditions;
public class IPv6AddressWithMask extends IPAddressWithMask<IPv6Address> {
public final static IPv6AddressWithMask NONE = of(IPv6Address.NONE, IPv6Address.NONE);
@@ -16,23 +15,17 @@
}
public static IPv6AddressWithMask of(IPv6Address value, IPv6Address mask) {
- if (value == null) {
- throw new NullPointerException("Value must not be null");
- }
- if (mask == null) {
- throw new NullPointerException("Mask must not be null");
- }
+ Preconditions.checkNotNull(value, "value must not be null");
+ Preconditions.checkNotNull(mask, "mask must not be null");
return new IPv6AddressWithMask(value, mask);
}
-
public static IPv6AddressWithMask of(final String string) {
- if (string == null) {
- throw new NullPointerException("String must not be null");
- }
+ Preconditions.checkNotNull(string, "string must not be null");
+
int slashPos;
String ip = string;
- int maskBits = 128;
+ int cidrMaskLength = 128;
IPv6Address maskAddress = null;
// Read mask suffix
@@ -47,14 +40,11 @@
maskAddress = IPv6Address.of(suffix);
} else {
// CIDR Suffix
- maskBits = Integer.parseInt(suffix);
+ cidrMaskLength = Integer.parseInt(suffix);
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
}
- if (maskBits < 0 || maskBits > 128) {
- throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
- }
}
// Read IP
@@ -63,30 +53,21 @@
if (maskAddress != null) {
// Full address mask
return IPv6AddressWithMask.of(ipv6, maskAddress);
- } else if (maskBits == 128) {
- // No mask
- return IPv6AddressWithMask.of(ipv6, IPv6Address.NO_MASK);
- } else if (maskBits == 0) {
- // Entirely masked out
- return IPv6AddressWithMask.of(ipv6, IPv6Address.FULL_MASK);
- }else {
- // With mask
- BigInteger mask = BigInteger.ONE.negate().shiftLeft(128 - maskBits);
- byte[] maskBytesTemp = mask.toByteArray();
- byte[] maskBytes;
- if (maskBytesTemp.length < 16) {
- maskBytes = new byte[16];
- System.arraycopy(maskBytesTemp, 0, maskBytes, 16 - maskBytesTemp.length, maskBytesTemp.length);
- Arrays.fill(maskBytes, 0, 16 - maskBytesTemp.length, (byte)(0xFF));
- } else if (maskBytesTemp.length > 16) {
- maskBytes = new byte[16];
- System.arraycopy(maskBytesTemp, 0, maskBytes, 0, maskBytes.length);
- } else {
- maskBytes = maskBytesTemp;
- }
- return IPv6AddressWithMask.of(ipv6, IPv6Address.of(maskBytes));
+ } else {
+ return IPv6AddressWithMask.of(ipv6,
+ IPv6Address.ofCidrMaskLength(cidrMaskLength));
}
}
+ @Override
+ public boolean contains(IPAddress<?> ip) {
+ Preconditions.checkNotNull(ip, "ip must not be null");
+ if(ip.getIpVersion() == IPVersion.IPv6) {
+ IPv6Address ipv6 = (IPv6Address) ip;
+ return this.matches(ipv6);
+ }
+
+ return false;
+ }
}