Lines Matching defs:prefixLength
158 * @param prefixLength
161 public static int prefixLengthToNetmaskInt(int prefixLength)
163 if (prefixLength < 0 || prefixLength > 32) {
166 int value = 0xffffffff << (32 - prefixLength);
189 int prefixLength = Integer.bitCount(i);
191 if (trailingZeros != 32 - prefixLength) {
194 return prefixLength;
240 public static void maskRawAddress(byte[] array, int prefixLength) {
241 if (prefixLength < 0 || prefixLength > array.length * 8) {
243 " bytes has invalid prefix length " + prefixLength);
246 int offset = prefixLength / 8;
247 int remainder = prefixLength % 8;
260 * Get InetAddress masked with prefixLength. Will never return null.
262 * @param prefixLength the prefixLength used to mask the IP
264 public static InetAddress getNetworkPart(InetAddress address, int prefixLength) {
266 maskRawAddress(array, prefixLength);
299 int prefixLength = -1;
302 prefixLength = Integer.parseInt(pieces[1]);
310 if (address == null || prefixLength == -1) {
314 return new Pair<InetAddress, Integer>(address, prefixLength);