Package com.baremaps.iploc.data
Class Ipv4Range
java.lang.Object
com.baremaps.iploc.data.Ipv4Range
Represents an IP range from a start IP to an end IP stored into longs because Java and Sqlite do not have unsigned 32
bits integers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(byte[] ip) Format an IP from a byte array into a string We need to prepend a byte of value 0 to the byte array so that the MSB is 0 in the two's-complement binary representationbyte[]getEnd()Returns the last IP in the rangebyte[]getStart()Returns the first IP in the rangetoString()
-
Constructor Details
-
Ipv4Range
Constructs an Ipv4 range from a String- Parameters:
range- the range in format "192.168.0.1 - 192.168.0.255" or "192.168.0.1/24"
-
Ipv4Range
public Ipv4Range(byte[] start, byte[] end) Constructs an Ipv4 range from a start and end ips- Parameters:
start-end-
-
-
Method Details
-
format
Format an IP from a byte array into a string We need to prepend a byte of value 0 to the byte array so that the MSB is 0 in the two's-complement binary representation- Parameters:
ip- the IP in a byte array- Returns:
- teh formatted IP
-
getStart
public byte[] getStart()Returns the first IP in the range- Returns:
- the first IP in the range
-
getEnd
public byte[] getEnd()Returns the last IP in the range- Returns:
- the last IP in the range
-
toString
-