Commit 4b835a81 authored by Youness Alaoui's avatar Youness Alaoui
Browse files

Add nice_address_ip_version API to NiceAddress

parent bb42398d
...@@ -363,3 +363,17 @@ nice_address_is_valid (const NiceAddress *a) ...@@ -363,3 +363,17 @@ nice_address_is_valid (const NiceAddress *a)
return FALSE; return FALSE;
} }
} }
NICEAPI_EXPORT int
nice_address_ip_version (const NiceAddress *addr)
{
switch (addr->s.addr.sa_family)
{
case AF_INET:
return 4;
case AF_INET6:
return 6;
default:
return 0;
}
}
...@@ -275,6 +275,18 @@ G_GNUC_WARN_UNUSED_RESULT ...@@ -275,6 +275,18 @@ G_GNUC_WARN_UNUSED_RESULT
gboolean gboolean
nice_address_is_valid (const NiceAddress *addr); nice_address_is_valid (const NiceAddress *addr);
/**
* nice_address_ip_version:
* @addr: The #NiceAddress to query
*
* Returns the IP version of the address
*
* Returns: 4 for IPv4, 6 for IPv6 and 0 for undefined address
*/
G_GNUC_WARN_UNUSED_RESULT
int
nice_address_ip_version (const NiceAddress *addr);
G_END_DECLS G_END_DECLS
#endif /* _ADDRESS_H */ #endif /* _ADDRESS_H */
......
...@@ -4,6 +4,7 @@ nice_address_equal ...@@ -4,6 +4,7 @@ nice_address_equal
nice_address_free nice_address_free
nice_address_get_port nice_address_get_port
nice_address_init nice_address_init
nice_address_ip_version
nice_address_is_private nice_address_is_private
nice_address_is_valid nice_address_is_valid
nice_address_new nice_address_new
......
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