diff --git a/include/sigar_format.h b/include/sigar_format.h index 620a8a21..2f9c8d4a 100644 --- a/include/sigar_format.h +++ b/include/sigar_format.h @@ -49,8 +49,9 @@ SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar, sigar_net_address_t *address, char *addr_str); -SIGAR_DECLARE(sigar_uint32_t) sigar_net_address_hash(sigar_net_address_t *address); +SIGAR_DECLARE(const char *)sigar_net_scope_to_string(int type); +SIGAR_DECLARE(sigar_uint32_t) sigar_net_address_hash(sigar_net_address_t *address); SIGAR_DECLARE(const char *)sigar_net_connection_type_get(int type); diff --git a/src/sigar_format.c b/src/sigar_format.c index 5aab7eb2..0be1f3a5 100644 --- a/src/sigar_format.c +++ b/src/sigar_format.c @@ -406,6 +406,24 @@ SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar, } } +SIGAR_DECLARE(const char *)sigar_net_scope_to_string(int type) +{ + switch (type) { + case SIGAR_IPV6_ADDR_ANY: + return "Global"; + case SIGAR_IPV6_ADDR_LOOPBACK: + return "Host"; + case SIGAR_IPV6_ADDR_LINKLOCAL: + return "Link"; + case SIGAR_IPV6_ADDR_SITELOCAL: + return "Site"; + case SIGAR_IPV6_ADDR_COMPATv4: + return "Compat"; + default: + return "Unknown"; + } +} + SIGAR_DECLARE(sigar_uint32_t) sigar_net_address_hash(sigar_net_address_t *address) { sigar_uint32_t hash = 0;