public class IPAddressHelper
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static int |
IPv4_FULL_MASK |
private static int |
IPv6_FULL_MASK |
private static int |
IPv6_HALF_MASK |
| Constructor and Description |
|---|
IPAddressHelper() |
| Modifier and Type | Method and Description |
|---|---|
private static int |
getCidrNetmask(int size,
byte[] netmask,
int offset) |
private static int |
getInt(byte[] bytes,
int offset)
Returns the big-endian
int value whose byte representation is
the 4 bytes of bytes staring offset. |
private static long |
getLong(byte[] bytes,
int offset)
Returns the big-endian
long value whose byte representation
is the 8 bytes of bytes staring offset. |
static boolean |
isWithinAddressSpace(byte[] ipBytes,
byte[] ipAddressWithNetmask)
Tests whether the ipAddress is within the address space defined by
the ipAddressWithNetmask.
|
private static final int IPv4_FULL_MASK
private static final int IPv6_FULL_MASK
private static final int IPv6_HALF_MASK
public static boolean isWithinAddressSpace(byte[] ipBytes,
byte[] ipAddressWithNetmask)
ipBytes - The IP address bytes to compare against the address
space.ipAddressWithNetmask - The 8 (IPv4) or 32 (IPv6) byte array containing in the
first half the base IP address bytes and in the second
half the netmask bytes.private static long getLong(byte[] bytes,
int offset)
long value whose byte representation
is the 8 bytes of bytes staring offset.bytes - offset - private static int getInt(byte[] bytes,
int offset)
int value whose byte representation is
the 4 bytes of bytes staring offset.bytes - offset - private static int getCidrNetmask(int size,
byte[] netmask,
int offset)