Commit f1df61dc authored by Dafydd Harries's avatar Dafydd Harries

address/: support converting IPv6 addresses to strings

darcs-hash:20070212130249-c9803-5c79bc290b79171ffcf062bc59092f900e2c6603.gz
parent 1772be3b
......@@ -57,14 +57,22 @@ nice_address_set_ipv4_from_string (NiceAddress *addr, const gchar *str)
gchar *
nice_address_to_string (NiceAddress *addr)
{
struct in_addr iaddr;
gchar ip_str[INET_ADDRSTRLEN];
const gchar *ret;
struct in_addr iaddr = {0,};
gchar ip_str[INET6_ADDRSTRLEN] = {0,};
const gchar *ret = NULL;
switch (addr->type)
{
case NICE_ADDRESS_TYPE_IPV4:
iaddr.s_addr = htonl (addr->addr_ipv4);
ret = inet_ntop (AF_INET, &iaddr, ip_str, INET_ADDRSTRLEN);
break;
case NICE_ADDRESS_TYPE_IPV6:
ret = inet_ntop (AF_INET6, &addr->addr_ipv6, ip_str, INET6_ADDRSTRLEN);
break;
}
g_assert (addr->type == NICE_ADDRESS_TYPE_IPV4);
iaddr.s_addr = htonl (addr->addr_ipv4);
ret = inet_ntop (AF_INET, &iaddr, ip_str, INET_ADDRSTRLEN);
g_assert (ret);
g_assert (ret == ip_str);
return g_strdup (ip_str);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment