private static int matchAddress(Matcher matcher) { int addr = 0; for (int i = 1; i <= 4; ++i) { int n = (rangeCheck(Integer.parseInt(matcher.group(i)), 0, 255)); addr |= ((n & 0xff) << 8*(4-i)); } return addr; }
private static int matchAddress(Matcher matcher) { int addr = 0; for (int i = 1; i <= 4; ++i) { int n = (rangeCheck(Integer.parseInt(matcher.group(i)), 0, 255)); addr |= ((n & 0xff) << 8*(4-i)); } return addr; }
private static int matchAddress(Matcher matcher) { int addr = 0; for (int i = 1; i <= 4; ++i) { int n = (rangeCheck(Integer.parseInt(matcher.group(i)), 0, 255)); addr |= ((n & 0xff) << 8*(4-i)); } return addr; }
private static int matchAddress(Matcher matcher) { int addr = 0; for (int i = 1; i <= 4; ++i) { int n = (rangeCheck(Integer.parseInt(matcher.group(i)), 0, 255)); addr |= ((n & 0xff) << 8*(4-i)); } return addr; }
private void calculate(String mask) { Matcher matcher = cidrPattern.matcher(mask); if (matcher.matches()) { address = matchAddress(matcher); /* Create a binary netmask from the number of bits specification /x */ int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS); for (int j = 0; j < cidrPart; ++j) { netmask |= (1 << 31 - j); } /* Calculate base network address */ network = (address & netmask); /* Calculate broadcast address */ broadcast = network | ~(netmask); } else { throw new IllegalArgumentException("Could not parse [" + mask + "]"); } }
private void calculate(String mask) { Matcher matcher = cidrPattern.matcher(mask); if (matcher.matches()) { address = matchAddress(matcher); /* Create a binary netmask from the number of bits specification /x */ int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS); for (int j = 0; j < cidrPart; ++j) { netmask |= (1 << 31 - j); } /* Calculate base network address */ network = (address & netmask); /* Calculate broadcast address */ broadcast = network | ~(netmask); } else { throw new IllegalArgumentException("Could not parse [" + mask + "]"); } }
private void calculate(String mask) { Matcher matcher = cidrPattern.matcher(mask); if (matcher.matches()) { address = matchAddress(matcher); /* Create a binary netmask from the number of bits specification /x */ int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS); for (int j = 0; j < cidrPart; ++j) { netmask |= (1 << 31 - j); } /* Calculate base network address */ network = (address & netmask); /* Calculate broadcast address */ broadcast = network | ~(netmask); } else { throw new IllegalArgumentException("Could not parse [" + mask + "]"); } }
private void calculate(String mask) { Matcher matcher = cidrPattern.matcher(mask); if (matcher.matches()) { address = matchAddress(matcher); /* Create a binary netmask from the number of bits specification /x */ int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS); for (int j = 0; j < cidrPart; ++j) { netmask |= (1 << 31 - j); } /* Calculate base network address */ network = (address & netmask); /* Calculate broadcast address */ broadcast = network | ~(netmask); } else { throw new IllegalArgumentException("Could not parse [" + mask + "]"); } }