Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. if (matcher.matches()) {
  2. address = matchAddress(matcher);
  3.  
  4. /* Create a binary netmask from the number of bits specification /x */
  5. int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS);
  6. for (int j = 0; j < cidrPart; ++j) {
  7. netmask |= (1 << 31-j);
  8. }
  9.  
  10. /* Calculate base network address */
  11. network = (address & netmask);
  12.  
  13. /* Calculate broadcast address */
  14. broadcast = network | ~(netmask);
  15. } else {
  16. throw new IllegalArgumentException("Could not parse [" + mask + "]");
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement