Removed the check that only picked private address space addresses. Now we pick IPv4 address belonging in any category that is not loopback address.
Change-Id: Idf98d1c64306059029bc4a6347d1ff952d45a6ba
Signed-off-by: Abhishek Kumar <abhishk2@cisco.com>
e = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e1) {
_logger.error("Failed to get list of interfaces", e1);
e = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e1) {
_logger.error("Failed to get list of interfaces", e1);
- //throw new RuntimeException("Failed to acquire list of interfaces", e1);
return null;
}
while (e.hasMoreElements()) {
return null;
}
while (e.hasMoreElements()) {
while (ee.hasMoreElements()) {
InetAddress i = (InetAddress) ee.nextElement();
_logger.debug("Trying address {}", i);
while (ee.hasMoreElements()) {
InetAddress i = (InetAddress) ee.nextElement();
_logger.debug("Trying address {}", i);
- if ((i instanceof Inet4Address) && (i.isSiteLocalAddress())) {
+ if ((i instanceof Inet4Address) && (!i.isLoopbackAddress())) {
String hostAddress = i.getHostAddress();
_logger.debug("Settled on host address {}", hostAddress);
return hostAddress;
String hostAddress = i.getHostAddress();
_logger.debug("Settled on host address {}", hostAddress);
return hostAddress;