summaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2013-02-01 19:17:59 -0500
committerYouness Alaoui <youness.alaoui@collabora.co.uk>2013-02-01 19:17:59 -0500
commit4b835a8119de7ade034bc91e8d4bc385b8cda166 (patch)
tree3bbfa32cc10b8f25ce11c4962848c9345dc0f154 /agent
parentbb42398d48f69221984effe1689150b5b0ea9f51 (diff)
downloadlibnice-4b835a8119de7ade034bc91e8d4bc385b8cda166.tar.gz
Add nice_address_ip_version API to NiceAddress
Diffstat (limited to 'agent')
-rw-r--r--agent/address.c14
-rw-r--r--agent/address.h12
2 files changed, 26 insertions, 0 deletions
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 */