org.opennms.core.utils
Class InetAddressUtils

java.lang.Object
  extended by org.opennms.core.utils.InetAddressUtils

public abstract class InetAddressUtils
extends Object

Abstract InetAddressUtils class.

Version:
$Id: $
Author:
Mathew Brozowski

Nested Class Summary
static class InetAddressUtils.AddressType
           
 
Field Summary
static InetAddress UNPINGABLE_ADDRESS
           
static InetAddress UNPINGABLE_ADDRESS_IPV6
           
 
Constructor Summary
InetAddressUtils()
           
 
Method Summary
static InetAddress addr(String ipAddrString)
           
static InetAddress convertBigIntegerIntoInetAddress(BigInteger i)
           
static InetAddress convertCidrToInetAddressV4(int cidr)
           
static InetAddress convertCidrToInetAddressV6(int cidr)
           
static byte[] decr(byte[] address)
           
static String decr(String address)
           
static BigInteger difference(InetAddress addr1, InetAddress addr2)
           
static BigInteger difference(String addr1, String addr2)
           
static InetAddress getInetAddress(byte[] ipAddrOctets)
          getInetAddress
static InetAddress getInetAddress(int[] octets, int offset, int length)
          getInetAddress
static InetAddress getInetAddress(String dottedNotation)
          getInetAddress
static InetAddress getLocalHostAddress()
           
static String getLocalHostAddressAsString()
           
static String getLocalHostName()
           
static InetAddress getLowestInetAddress(List<InetAddress> addresses)
          Given a list of IP addresses, return the lowest as determined by the numeric representation and not the alphanumeric string.
static byte[] incr(byte[] address)
           
static String incr(String address)
           
static boolean inSameScope(InetAddress addr1, InetAddress addr2)
           
static boolean isInetAddressInRange(byte[] addr, byte[] begin, byte[] end)
           
static boolean isInetAddressInRange(byte[] laddr, String beginString, String endString)
           
static boolean isInetAddressInRange(String ipAddr, byte[] begin, byte[] end)
           
static boolean isInetAddressInRange(String addrString, String beginString, String endString)
           
static String macAddressBytesToString(byte[] macAddress)
           
static byte[] macAddressStringToBytes(String macAddress)
           
static String normalize(String ipAddrString)
          This function is used to ensure that an IP address string is in fully-qualified format without any "::" segments for an IPv6 address.
static String normalizeMacAddress(String macAddress)
           
static InetAddress resolveHostname(String hostname, boolean preferInet6Address)
           
static InetAddress resolveHostname(String hostname, boolean preferInet6Address, boolean throwException)
          This function is used inside XSLT documents, do a string search before refactoring.
static String str(InetAddress addr)
           
static BigInteger toInteger(InetAddress ipAddress)
           
static byte[] toIpAddrBytes(String dottedNotation)
          toIpAddrBytes
static String toIpAddrString(byte[] addr)
          toIpAddrString
static String toIpAddrString(InetAddress addr)
          toIpAddrString
static String toOid(InetAddress addr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNPINGABLE_ADDRESS

public static final InetAddress UNPINGABLE_ADDRESS

UNPINGABLE_ADDRESS_IPV6

public static final InetAddress UNPINGABLE_ADDRESS_IPV6
Constructor Detail

InetAddressUtils

public InetAddressUtils()
Method Detail

getLocalHostAddress

public static InetAddress getLocalHostAddress()

getLocalHostAddressAsString

public static String getLocalHostAddressAsString()

getLocalHostName

public static String getLocalHostName()

incr

public static String incr(String address)
                   throws UnknownHostException
Throws:
UnknownHostException

incr

public static byte[] incr(byte[] address)
                   throws UnknownHostException
Throws:
UnknownHostException

decr

public static String decr(String address)
                   throws UnknownHostException
Throws:
UnknownHostException

decr

public static byte[] decr(byte[] address)
                   throws UnknownHostException
Throws:
UnknownHostException

getInetAddress

public static InetAddress getInetAddress(int[] octets,
                                         int offset,
                                         int length)

getInetAddress

Parameters:
ipAddrOctets - an array of byte.
Returns:
a InetAddress object.

getInetAddress

public static InetAddress getInetAddress(byte[] ipAddrOctets)

getInetAddress

Parameters:
ipAddrOctets - an array of byte.
Returns:
a InetAddress object.

getInetAddress

public static InetAddress getInetAddress(String dottedNotation)

getInetAddress

Parameters:
dottedNotation - a String object.
Returns:
a InetAddress object.

resolveHostname

public static InetAddress resolveHostname(String hostname,
                                          boolean preferInet6Address)
                                   throws UnknownHostException
Throws:
UnknownHostException

resolveHostname

public static InetAddress resolveHostname(String hostname,
                                          boolean preferInet6Address,
                                          boolean throwException)
                                   throws UnknownHostException
This function is used inside XSLT documents, do a string search before refactoring.

Throws:
UnknownHostException

toIpAddrBytes

public static byte[] toIpAddrBytes(String dottedNotation)

toIpAddrBytes

Parameters:
dottedNotation - a String object.
Returns:
an array of byte.

toIpAddrString

public static String toIpAddrString(InetAddress addr)

toIpAddrString

Parameters:
addr - IP address
Returns:
a String object.

toIpAddrString

public static String toIpAddrString(byte[] addr)

toIpAddrString

Parameters:
addr - an array of byte.
Returns:
a String object.

getLowestInetAddress

public static InetAddress getLowestInetAddress(List<InetAddress> addresses)
Given a list of IP addresses, return the lowest as determined by the numeric representation and not the alphanumeric string.

Parameters:
addresses - a List object.
Returns:
a InetAddress object.

difference

public static BigInteger difference(String addr1,
                                    String addr2)

difference

public static BigInteger difference(InetAddress addr1,
                                    InetAddress addr2)

isInetAddressInRange

public static boolean isInetAddressInRange(byte[] laddr,
                                           String beginString,
                                           String endString)

isInetAddressInRange

public static boolean isInetAddressInRange(String addrString,
                                           String beginString,
                                           String endString)

inSameScope

public static boolean inSameScope(InetAddress addr1,
                                  InetAddress addr2)

isInetAddressInRange

public static boolean isInetAddressInRange(byte[] addr,
                                           byte[] begin,
                                           byte[] end)

isInetAddressInRange

public static boolean isInetAddressInRange(String ipAddr,
                                           byte[] begin,
                                           byte[] end)

convertCidrToInetAddressV4

public static InetAddress convertCidrToInetAddressV4(int cidr)

convertCidrToInetAddressV6

public static InetAddress convertCidrToInetAddressV6(int cidr)

convertBigIntegerIntoInetAddress

public static InetAddress convertBigIntegerIntoInetAddress(BigInteger i)
                                                    throws UnknownHostException
Throws:
UnknownHostException

addr

public static InetAddress addr(String ipAddrString)

normalize

public static String normalize(String ipAddrString)
This function is used to ensure that an IP address string is in fully-qualified format without any "::" segments for an IPv6 address. FIXME: do we lose


str

public static String str(InetAddress addr)

toInteger

public static BigInteger toInteger(InetAddress ipAddress)

toOid

public static String toOid(InetAddress addr)

macAddressStringToBytes

public static byte[] macAddressStringToBytes(String macAddress)

macAddressBytesToString

public static String macAddressBytesToString(byte[] macAddress)

normalizeMacAddress

public static String normalizeMacAddress(String macAddress)


Copyright © 2011. All Rights Reserved.