broaden inet_ntop support
This commit is contained in:
parent
8f393ee9cc
commit
4e9ee330df
17
src/sigar.c
17
src/sigar.c
|
@ -1864,22 +1864,29 @@ SIGAR_DECLARE(int) sigar_net_address_equals(sigar_net_address_t *addr1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(WIN32) && !defined(NETWARE) && !defined(__hpux)
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#define sigar_inet_ntop inet_ntop
|
||||||
|
#define sigar_inet_ntop_errno errno
|
||||||
|
#else
|
||||||
|
#define sigar_inet_ntop(af, src, dst, size) NULL
|
||||||
|
#define sigar_inet_ntop_errno EINVAL
|
||||||
|
#endif
|
||||||
|
|
||||||
SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar,
|
SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar,
|
||||||
sigar_net_address_t *address,
|
sigar_net_address_t *address,
|
||||||
char *addr_str)
|
char *addr_str)
|
||||||
{
|
{
|
||||||
switch (address->family) {
|
switch (address->family) {
|
||||||
case SIGAR_AF_INET6:
|
case SIGAR_AF_INET6:
|
||||||
#if defined(__linux__) /*XXX*/
|
if (sigar_inet_ntop(AF_INET6, (const void *)&address->addr.in6,
|
||||||
if (inet_ntop(AF_INET6, (const void *)&address->addr.in6,
|
addr_str, SIGAR_INET6_ADDRSTRLEN))
|
||||||
addr_str, SIGAR_INET6_ADDRSTRLEN))
|
|
||||||
{
|
{
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return errno;
|
return sigar_inet_ntop_errno;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
case SIGAR_AF_INET:
|
case SIGAR_AF_INET:
|
||||||
return sigar_inet_ntoa(sigar, address->addr.in, addr_str);
|
return sigar_inet_ntoa(sigar, address->addr.in, addr_str);
|
||||||
case SIGAR_AF_UNSPEC:
|
case SIGAR_AF_UNSPEC:
|
||||||
|
|
Loading…
Reference in New Issue