Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. public long toLong() {
  2. long t = (long) first << 24 | (long) second << 16 | (long) third << 8 | (long) fourth;
  3. if (mask == 32) return t;
  4. else return t - (t % toHostMask());
  5. }
  6.  
  7. public long toHostMask() {
  8. return (long) 1 << (32 - mask);
  9. }
  10.  
  11. public boolean in(IPAddress address) {
  12. long thisLong = this.toLong();
  13. long addressLong = address.toLong();
  14. return thisLong >= addressLong && thisLong <= (addressLong + address.toHostMask() - 1);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement