adjustments for ipv6

This commit is contained in:
Doug MacEachern 2006-02-28 20:53:58 +00:00
parent bfad6a3193
commit 00a7b17f94
2 changed files with 12 additions and 6 deletions

View File

@ -659,11 +659,17 @@ public class Sigar implements SigarProxy {
} }
if (conn.getLocalPort() == port) { if (conn.getLocalPort() == port) {
if (conn.getLocalAddress().equals(NetFlags.ANY_ADDR)) { String address =
conn.getLocalAddress();
if (address.equals(NetFlags.ANY_ADDR)) {
return NetFlags.LOOPBACK_ADDRESS; return NetFlags.LOOPBACK_ADDRESS;
} }
else if (address.equals(NetFlags.ANY_ADDR_V6)) {
return NetFlags.LOOPBACK_ADDRESS_V6;
}
else { else {
return conn.getLocalAddress(); return address;
} }
} }
} }

View File

@ -110,12 +110,12 @@ public class Netstat extends SigarCommandBase {
String port = formatPort(proto, portnum); String port = formatPort(proto, portnum);
String address; String address;
if (isNumeric) { if (NetFlags.isAnyAddress(ip)) {
address = ip;
}
else if (ip.equals(NetFlags.ANY_ADDR)) {
address = "*"; address = "*";
} }
else if (isNumeric) {
address = ip;
}
else { else {
try { try {
address = InetAddress.getByName(ip).getHostName(); address = InetAddress.getByName(ip).getHostName();