Skip to content

Commit

Permalink
Remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo committed Nov 18, 2024
1 parent 5204421 commit 6354a96
Showing 1 changed file with 0 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,6 @@ public int hashCode() {
return Arrays.hashCode(ip);
}

/**
* Check if the IP address is 0
*
* @return true if IP address is 0 false if IP address is not 0
*/
public static boolean isNull(byte[] addr) {

if (addr == null || isEqual(addr, nullAddr)) {
return true;
} else {
return false;
}
}

/**
* Check if two raw IP addresses are equal. Handles either or both buffers being null. If they are both null they are
* considered equal.
Expand Down Expand Up @@ -212,26 +198,6 @@ public byte[] getAddressUnsafe() {
return ip;
}

/**
* Get the IP address as an IPv4 address.
*
* @return The raw IP address if the current address is an IPv4 address (or an IPv4-mapped IPv6) address.
*
* @throws IllegalArgumentException if the current address is not an IPv4 address.
*/
public byte[] getIPv4Address() {

if (getType() != IPV4 && getType() != IPV4MAC) {
throw new IllegalArgumentException("Address is not an IPv4 or IPv4-mapped IPv6 address");
}

byte[] buf = new byte[4];
// Copy lower four bytes into return buffer
System.arraycopy(ip, prefix.length, buf, 0, buf.length);

return buf;
}

/**
* Set a 48 bit MAC address into an iPv4-mapped IPv6 address.
*/
Expand All @@ -253,45 +219,6 @@ public void setMac(byte[] mac) {
type = IPV4MAC;
}

/**
* Set a 48 bit MAC address into an iPv4-mapped IPv6 address. This must be called AFTER an IPv4 address is set.
*/
public byte[] getMac() {
if (getType() != IPV4MAC) {
throw new IllegalArgumentException();
}

byte[] mac = new byte[6];

// Copy Mac address into bytes 4-9
System.arraycopy(ip, 4, mac, 0, mac.length);
return mac;
}

/**
* Get the IP address as an IPv4 integer address.
*
* @return The integer IP address if the current address is an IPv4 address or an IPv4-mapped IPv6 address.
*
* @throws IllegalArgumentException if the current address is not an IPv4 address.
*/
public int getIPv4AddressAsInt() {

if (getType() != IPV4 && getType() != IPV4MAC) {
throw new IllegalArgumentException("Address is not an IPv4 or IPv4-mapped IPv6 address");
}

int address;

// Generate address from last 4 bytes of address buffer
address = ip[15] & 0xFF;
address |= ((ip[14] << 8) & 0xFF00);
address |= ((ip[13] << 16) & 0xFF0000);
address |= ((ip[12] << 24) & 0xFF000000);

return address;
}

/**
* Set the IP address.
*
Expand Down Expand Up @@ -398,13 +325,6 @@ public String toString() {
return rawIPToString(ip, true, false);
}

/**
* Converts a raw IP address to a readable String.
*/
public static String rawIPToString(byte[] addr) {
return rawIPToString(addr, true, false);
}

/**
* Converts a raw IP address to a readable String.
*/
Expand Down

0 comments on commit 6354a96

Please sign in to comment.