@Test public void testNetmaskOdd() { Cidr c = new Cidr("10.0/13"); Assert.assertEquals(c.netmask().getHostAddress(), "255.31.0.0"); }
public InetAddress netmask() { final byte[] netmaskBytes = new byte[] { 0, 0, 0, 0 }; int lengthLeft = length; int i=0; while (lengthLeft>0) { if (lengthLeft>=8) { netmaskBytes[i] = (byte)255; } else { netmaskBytes[i] = (byte) ( (1 << lengthLeft) - 1 ); } lengthLeft -= 8; i++; } return Networking.getInetAddressWithFixedName(netmaskBytes); }
Cidr implements Serializable { public InetAddress netmask() { final byte[] netmaskBytes = new byte[] { 0, 0, 0, 0 }; int lengthLeft = length; int i=0; while (lengthLeft>0) { if (lengthLeft>=8) { netmaskBytes[i] = (byte)255; } else { netmaskBytes[i] = (byte) ( (1 << lengthLeft) - 1 ); } lengthLeft -= 8; i++; } return Networking.getInetAddressWithFixedName(netmaskBytes); } }
Cidr implements Serializable { public InetAddress netmask() { final byte[] netmaskBytes = new byte[] { 0, 0, 0, 0 }; int lengthLeft = length; int i=0; while (lengthLeft>0) { if (lengthLeft>=8) { netmaskBytes[i] = (byte)255; } else { netmaskBytes[i] = (byte) ( (1 << lengthLeft) - 1 ); } lengthLeft -= 8; i++; } return Networking.getInetAddressWithFixedName(netmaskBytes); } Cidr(String cidr);  Cidr(int ...unsignedBytes);  Cidr(int[] subnetBytes, int length); }
Cidr implements Serializable { public InetAddress netmask() { final byte[] netmaskBytes = new byte[] { 0, 0, 0, 0 }; int lengthLeft = length; int i=0; while (lengthLeft>0) { if (lengthLeft>=8) { netmaskBytes[i] = (byte)255; } else { netmaskBytes[i] = (byte) ( (1 << lengthLeft) - 1 ); } lengthLeft -= 8; i++; } return Networking.getInetAddressWithFixedName(netmaskBytes); } Cidr(String cidr);  Cidr(int ...unsignedBytes);  Cidr(int[] subnetBytes, int length); static boolean isCanonical(String cidr); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); int[] getBytes(); int getLength(); Cidr subnet(int ...extraUnsignedBytes); InetAddress netmask(); InetAddress addressAtOffset(int offset); int commonPrefixLength(Cidr other); Cidr commonPrefix(Cidr other); BitList asBitList(); boolean contains(Cidr target); @Deprecated static InetAddress getInetAddressWithFixedName(byte[] ip); }
Cidr implements Serializable { public InetAddress netmask() { final byte[] netmaskBytes = new byte[] { 0, 0, 0, 0 }; int lengthLeft = length; int i=0; while (lengthLeft>0) { if (lengthLeft>=8) { netmaskBytes[i] = (byte)255; } else { netmaskBytes[i] = (byte) ( (1 << lengthLeft) - 1 ); } lengthLeft -= 8; i++; } return Networking.getInetAddressWithFixedName(netmaskBytes); } Cidr(String cidr);  Cidr(int ...unsignedBytes);  Cidr(int[] subnetBytes, int length); static boolean isCanonical(String cidr); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); int[] getBytes(); int getLength(); Cidr subnet(int ...extraUnsignedBytes); InetAddress netmask(); InetAddress addressAtOffset(int offset); int commonPrefixLength(Cidr other); Cidr commonPrefix(Cidr other); BitList asBitList(); boolean contains(Cidr target); @Deprecated static InetAddress getInetAddressWithFixedName(byte[] ip); static final Cidr UNIVERSAL; static final Cidr _10; static final Cidr _172_16; static final Cidr _192_168; static final Cidr CLASS_A; static final Cidr CLASS_B; static final Cidr CLASS_C; static final List<Cidr> PRIVATE_NETWORKS_RFC_1918; static final Cidr _169_254; static final Cidr LINK_LOCAL; static final Cidr _127; static final Cidr LOOPBACK; static final List<Cidr> NON_PUBLIC_CIDRS; }