diff --git a/epan/address_types.c b/epan/address_types.c index c067775fb6..8de1c5403d 100644 --- a/epan/address_types.c +++ b/epan/address_types.c @@ -10,6 +10,7 @@ #include "config.h" #include /* for memcmp */ +#include #include "packet.h" #include "address_types.h" #include "to_str.h" @@ -426,12 +427,16 @@ static int eui64_len(void) static int ib_addr_to_str(const address *addr, gchar *buf, int buf_len) { - if (addr->len >= 16) { /* GID is 128bits */ - return ip6_to_str_buf_with_pfx((const ws_in6_addr *)addr->data, buf, buf_len, "GID: "); - } + char buf_ip6[WS_INET6_ADDRSTRLEN]; - /* this is a LID (16 bits) */ - g_snprintf(buf,buf_len,"LID: %u", *(const guint16 *)addr->data); + if (addr->len >= 16) { /* GID is 128bits */ + ws_inet_ntop6((const ws_in6_addr *)addr->data, buf_ip6, sizeof(buf_ip6)); + snprintf(buf, buf_len, "GID: %s", buf_ip6); + } + else { + /* this is a LID (16 bits) */ + snprintf(buf,buf_len,"LID: %u", *(const guint16 *)addr->data); + } return (int)(strlen(buf)+1); } diff --git a/wsutil/to_str.c b/wsutil/to_str.c index 9077306055..8c6125b662 100644 --- a/wsutil/to_str.c +++ b/wsutil/to_str.c @@ -606,24 +606,6 @@ char *ip6_to_str(wmem_allocator_t *scope, const ws_in6_addr *ad) return buf; } -int -ip6_to_str_buf_with_pfx(const ws_in6_addr *addr, gchar *buf, int buf_size, const char *prefix) -{ - int bytes; /* the number of bytes which would be produced if the buffer was large enough. */ - gchar addr_buf[WS_INET6_ADDRSTRLEN]; - int len; - - if (prefix == NULL) - prefix = ""; - bytes = g_snprintf(buf, buf_size, "%s%s", prefix, ws_inet_ntop6(addr, addr_buf, sizeof(addr_buf))); - len = bytes - 1; - - if (len > buf_size - 1) { /* size minus nul terminator */ - len = (int)g_strlcpy(buf, BUF_TOO_SMALL_ERR, buf_size); /* Let the unexpected value alert user */ - } - return len; -} - gchar * ipxnet_to_str_punct(wmem_allocator_t *allocator, const guint32 ad, const char punct) { diff --git a/wsutil/to_str.h b/wsutil/to_str.h index 08b3fe3678..a8d6f829fb 100644 --- a/wsutil/to_str.h +++ b/wsutil/to_str.h @@ -293,9 +293,6 @@ WS_DLL_PUBLIC void ip6_to_str_buf(const ws_in6_addr *ad, gchar *buf, size_t buf_ WS_DLL_PUBLIC char *ip6_to_str(wmem_allocator_t *scope, const ws_in6_addr *ad); -/* Returns length of the result. Takes a prefix to be inserted before the address. */ -WS_DLL_PUBLIC int ip6_to_str_buf_with_pfx(const ws_in6_addr *ad, gchar *buf, int buf_size, const char *prefix); - WS_DLL_PUBLIC gchar *ipxnet_to_str_punct(wmem_allocator_t *scope, const guint32 ad, const char punct); WS_DLL_PUBLIC gchar *eui64_to_str(wmem_allocator_t *scope, const guint64 ad);