KLALB V3.4

This commit is contained in:
Administrator
2025-11-15 11:08:16 +08:00
parent 306bfd36f7
commit 8842566ee2
160 changed files with 18540 additions and 4512 deletions
@@ -8,6 +8,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Objects;
import java.util.UUID;
public class Inet6AddressGroup implements Comparable<Inet6AddressGroup>{
private static final byte[][] maskTransf=new byte[129][16];
@@ -121,4 +122,21 @@ public class Inet6AddressGroup implements Comparable<Inet6AddressGroup>{
prefixLength=in.read();
}
public Inet6AddressGroup createPrefixOnlyAddressGroup(int newPrefixLength) {
byte[]mask=maskTransf[newPrefixLength];
byte[]andm=getAndm(mask);
try {
return new Inet6AddressGroup((Inet6Address) Inet6Address.getByAddress(andm), newPrefixLength);
} catch (UnknownHostException e) {
return null;
}
}
public Inet6AddressGroup createPrefixOnlyAddressGroup() {
return createPrefixOnlyAddressGroup(prefixLength);
}
public static void main(String[] args) throws UnknownHostException {
Inet6AddressGroup i6ag=new Inet6AddressGroup((Inet6Address) Inet6Address.getByName("1234:1234::1234"),12);
System.out.println(i6ag);
System.out.println(i6ag.createPrefixOnlyAddressGroup());
}
}