Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 + "]");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement