wsutil: Add ip_to_str()
This commit is contained in:
parent
8c4a479c52
commit
d4c7978f68
|
@ -578,6 +578,15 @@ ip_to_str_buf(const guint8 *ad, gchar *buf, const int buf_len)
|
|||
*b=0;
|
||||
}
|
||||
|
||||
char *ip_to_str(wmem_allocator_t *scope, const guint8 *ad)
|
||||
{
|
||||
char *buf = wmem_alloc(scope, WS_INET_ADDRSTRLEN * sizeof(char));
|
||||
|
||||
ip_to_str_buf(ad, buf, WS_INET_ADDRSTRLEN);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
ip6_to_str_buf(const ws_in6_addr *addr, gchar *buf, int buf_size)
|
||||
{
|
||||
|
@ -593,6 +602,15 @@ ip6_to_str_buf(const ws_in6_addr *addr, gchar *buf, int buf_size)
|
|||
return len;
|
||||
}
|
||||
|
||||
char *ip6_to_str(wmem_allocator_t *scope, const ws_in6_addr *ad)
|
||||
{
|
||||
char *buf = wmem_alloc(scope, WS_INET6_ADDRSTRLEN * sizeof(char));
|
||||
|
||||
ip6_to_str_buf(ad, buf, WS_INET6_ADDRSTRLEN);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
ip6_to_str_buf_with_pfx(const ws_in6_addr *addr, gchar *buf, int buf_size, const char *prefix)
|
||||
{
|
||||
|
|
|
@ -286,9 +286,13 @@ WS_DLL_PUBLIC void guint64_to_str_buf(guint64 u, gchar *buf, int buf_len);
|
|||
|
||||
WS_DLL_PUBLIC void ip_to_str_buf(const guint8 *ad, gchar *buf, const int buf_len);
|
||||
|
||||
WS_DLL_PUBLIC char *ip_to_str(wmem_allocator_t *scope, const guint8 *ad);
|
||||
|
||||
/* Returns length of the result. */
|
||||
WS_DLL_PUBLIC int ip6_to_str_buf(const ws_in6_addr *ad, gchar *buf, int buf_size);
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue