From 4b835a8119de7ade034bc91e8d4bc385b8cda166 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Fri, 1 Feb 2013 19:17:59 -0500 Subject: Add nice_address_ip_version API to NiceAddress --- agent/address.c | 14 ++++++++++++++ agent/address.h | 12 ++++++++++++ 2 files changed, 26 insertions(+) (limited to 'agent') diff --git a/agent/address.c b/agent/address.c index 5efd55a..b441a54 100644 --- a/agent/address.c +++ b/agent/address.c @@ -363,3 +363,17 @@ nice_address_is_valid (const NiceAddress *a) 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; + } +} diff --git a/agent/address.h b/agent/address.h index 17c5b3e..46d733f 100644 --- a/agent/address.h +++ b/agent/address.h @@ -275,6 +275,18 @@ G_GNUC_WARN_UNUSED_RESULT gboolean 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 #endif /* _ADDRESS_H */ -- cgit v1.2.1