Use IPv6 subnet mask calculation as suggested by @andi-bigswitch
Reference:
https://github.com/ronaldchl/loxigen/commit/fea1789f36d0edba5cf991ff0a953e9ef445f078#commitcomment-6923088
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 dcbd4a1..29a3726 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
@@ -1,6 +1,5 @@
package org.projectfloodlight.openflow.types;
-import java.math.BigInteger;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.Arrays;
@@ -322,23 +321,11 @@
} else if (cidrMaskLength == 0) {
return IPv6Address.FULL_MASK;
} else {
- BigInteger mask
- = BigInteger.ONE.negate().shiftLeft(128 - cidrMaskLength);
- 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 IPv6Address.of(maskBytes);
+ int shift1 = Math.min(cidrMaskLength, 64);
+ long raw1 = shift1 == 0 ? 0 : (long) -1 << (64 - shift1);
+ int shift2 = Math.max(cidrMaskLength - 64, 0);
+ long raw2 = shift2 == 0 ? 0 : (long) -1 << (64 - shift2);
+ return IPv6Address.of(raw1, raw2);
}
}