forked from KNEMC/KLALB
KLALB V3.4
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user