|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--SSF.OS.BGP4.Util.IPaddress
Each instance of this class represents an IPv4 address.
| Field Summary | |
static long |
MAX_IP
The integer value of the "maximum" IPv4 address: 255.255.255.255. |
| Constructor Summary | |
IPaddress()
Default constructor: constructs the IP address 1.1.1.1/32. |
|
IPaddress(boolean[] bin)
Constructs an IP address using a boolean array. |
|
IPaddress(byte[] bytes)
Constructs an IP address given an array of five bytes. |
|
IPaddress(int v)
Constructs an IP address using an integer as the address's value. |
|
IPaddress(int v,
int pre)
Constructs an IP address with the given integer value and prefix length. |
|
IPaddress(IPaddress ipa)
Copy constructor. |
|
IPaddress(long v)
Constructs an IP address using a (long) integer as the address's value. |
|
IPaddress(long v,
int pre)
Constructs an IP address with the given (long) integer value and prefix length. |
|
IPaddress(java.lang.String str)
Constructs an IP address using a string. |
|
| Method Summary | |
static java.lang.String |
bin2str(boolean[] b)
Converts an IP address from boolean array format to string format. |
boolean[] |
binval()
Returns the IP address in boolean array format, where the size of the array returned is the same as the prefix length. |
boolean[] |
binval(boolean fullsize)
Returns the IP address in boolean array format. |
int |
bit(int bitnum)
Returns the value of a single bit in the IP address. |
BitString |
bits()
Returns the bits in the IP address as a BitString of length 32 (prefix length is ignored). |
byte[] |
bytes()
Returns the IP address as an array of five bytes. |
static java.lang.String |
bytes2str(byte[] bytes)
Converts an array of five bytes into an IP address in string form. |
boolean |
equals(java.lang.Object ipaddr)
Determines whether two IP addresses are equal. |
IPaddress |
get_incr()
Creates a new IP address with the same value as this one, then increments the value of that IP address by one and returns it. |
IPaddress |
get_incr(int block)
Creates a new IP address with the same value as this one, then increments the value of that IP address by the given amount and returns it. |
int |
hashCode()
Returns a hash code value which can be used if an IP address is used as a key in a hash table. |
void |
incr()
Increment this IP address by 1. |
void |
incr(int block)
Increment this IP address by the given integer value. |
int |
intval()
Returns the value of IP address just as in val(), but returns
it as an integer, if possible, instead of a long integer. |
boolean |
is_prefix_of(IPaddress ipa)
Determines whether this IP address is a proper prefix of a given IP address. |
BitString |
masked_bits()
Returns the bits in the IP address, after being masked, as a BitString of length 32. |
int |
masked_intval()
Returns the masked value of the IP address just as in masked_val(), but returns it as a plain integer if possible. |
int |
masked_intval(int len)
Returns the masked value of the IP address just as in masked_val(int), but returns it as a plain integer if
possible. |
long |
masked_val()
Returns the value of the IP address when the bits beyond the prefix length are masked out (taken as zeroes). |
long |
masked_val(int len)
Returns the value of the IP address when the bits beyond a given point are masked out (taken as zeroes). |
BitString |
prefix_bits()
Returns only the prefix bits in the IP address as a BitString of length prefix_len. |
int |
prefix_len()
Returns the prefix length. |
void |
print_binary()
Prints the binary value of this IP address, ignoring prefix length. |
boolean |
same_prefix(IPaddress ipaddr)
Returns whether the given IP address prefix, when masked, is the same as this IP address prefix when masked. |
void |
set_prefix_len(int pre)
Set the prefix length to the given value. |
void |
set_val(int v)
Set the value of the IP address using an integer. |
void |
set_val(long v)
Set the value of the IP address using a long integer. |
void |
set(IPaddress ip)
Set the value of the IP address based on another IP address. |
static boolean[] |
str2bin(java.lang.String str)
Converts an IP address from string format to boolean array format. |
static int |
str2int(java.lang.String str)
Converts an IP address from string format to integer format. |
static long |
str2long(java.lang.String str)
Converts an IP address from string format to long integer format. |
java.lang.String |
toString()
Returns a string representing this IP address in dotted-quad (a.b.c.d/p) notation, including the prefix length. |
java.lang.String |
toString(boolean usenhi)
Converts an IP address object to a string. |
long |
val()
Returns the value of IP address when taken as a 32-bit number (prefix length ignored). |
java.lang.String |
val2str()
Returns a string representing this IP address in dotted-quad (a.b.c.d) notation, without prefix length. |
boolean |
valequals(IPaddress ipaddr)
Determines whether two IP addresses have equal values. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final long MAX_IP
| Constructor Detail |
public IPaddress()
public IPaddress(IPaddress ipa)
ipa - The IP address to copy.public IPaddress(int v)
v - The integer value of the IP address.public IPaddress(long v)
v - The (long) integer value of the IP address.
public IPaddress(int v,
int pre)
v - The integer value of the IP address.pre - The prefix length of the IP address.
public IPaddress(long v,
int pre)
v - The (long) integer value of the IP address.pre - The prefix length of the IP address.public IPaddress(byte[] bytes)
bytes - An array of bytes to be converted into an IP address.public IPaddress(boolean[] bin)
bin - An array of booleans which represents an IP address.public IPaddress(java.lang.String str)
str - The string representing an IP address.| Method Detail |
public static java.lang.String bytes2str(byte[] bytes)
bytes - An array of bytes to be converted into an IP address.
public static final java.lang.String bin2str(boolean[] b)
IPaddress(boolean[]) for an explanation of the
boolean array format.
b - A boolean array representing an IP address.
IPaddress(boolean[])public static final boolean[] str2bin(java.lang.String str)
str - A string representing the IP address to be converted.
public final int bit(int bitnum)
bitnum - The number of the bit to return.
public final BitString bits()
public final BitString masked_bits()
public final BitString prefix_bits()
prefix_len.
public final byte[] bytes()
public final boolean[] binval()
public final boolean[] binval(boolean fullsize)
fullsize
parameter determines whether or not the array length is 32 or
prefix_len.
fullsize - Whether or not to pad the array with zeroes (falses)
up to 32 if the prefix length is less than 32.
public final long val()
public final int intval()
val(), but returns
it as an integer, if possible, instead of a long integer. Some IP address
values may be too big to fit in a regular integer. This method exists
because in many cases it's easier to deal with an int than a
long.
public static final int str2int(java.lang.String str)
str - A string representing an IP address.
public static final long str2long(java.lang.String str)
str - A string representing an IP address.
public final void set_val(int v)
v - An integer to use as the value of the IP address.public final void set_val(long v)
v - A long integer to use as the value of the IP address.public final void set(IPaddress ip)
ip - An IP address to use as the value for this IP address.public final void set_prefix_len(int pre)
pre - The value to use as the new prefix length.public final int prefix_len()
public final IPaddress get_incr()
public final IPaddress get_incr(int block)
block - The amount by which to increment the IP address value.
public final void incr()
public final void incr(int block)
block - The amount by which to increment the IP address value.public final boolean valequals(IPaddress ipaddr)
ipaddr - The IP address with which to make the comparison.
public boolean equals(java.lang.Object ipaddr)
equals in class java.lang.Objectipaddr - The IP address with which to make the comparison.
public final boolean same_prefix(IPaddress ipaddr)
ipaddr - An IP address prefix for comparison.
public final long masked_val(int len)
len - The length in bits beyond which to mask the address.
public final long masked_val()
public final int masked_intval(int len)
masked_val(int), but returns it as a plain integer if
possible. Some IP address values may be too big to fit in an plain
integer. This method exists because in many cases it's easier to deal
with a plain integer than a long integer.
len - The length in bits beyond which to mask the address.
public final int masked_intval()
masked_val(), but returns it as a plain integer if possible.
Some IP address values may be too big to fit in an plain integer. This
method exists because in many cases it's easier to deal with a plain
integer than a long integer.
public final void print_binary()
public final java.lang.String val2str()
public final boolean is_prefix_of(IPaddress ipa)
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString(boolean usenhi)
usenhi - Whether to use the NHI or traditional address format.
public final java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||