diff options
author | Dafydd Harries <dafydd.harries@collabora.co.uk> | 2007-03-14 14:15:00 +0000 |
---|---|---|
committer | Dafydd Harries <dafydd.harries@collabora.co.uk> | 2007-03-14 14:15:00 +0000 |
commit | ff52edd716f545ce9c7a99c1867dc895b0b9d672 (patch) | |
tree | f7755a39f5bbe39382b76de909a542292818efef | |
parent | 5912af5e1809d7e3d778d7bb00dc4d7dcf7d50df (diff) | |
download | libnice-ff52edd716f545ce9c7a99c1867dc895b0b9d672.tar.gz |
nice_address_set_from_sockaddr_in ()
darcs-hash:20070314141500-c9803-e5e719ce1a96d9c9a859913ee5554264c1218225.gz
-rw-r--r-- | address/address.c | 19 | ||||
-rw-r--r-- | address/address.h | 5 | ||||
-rw-r--r-- | nice/libnice.symbols | 1 |
3 files changed, 25 insertions, 0 deletions
diff --git a/address/address.c b/address/address.c index 7c55515..380246f 100644 --- a/address/address.c +++ b/address/address.c @@ -54,6 +54,25 @@ nice_address_set_ipv4_from_string (NiceAddress *addr, const gchar *str) } +void +nice_address_set_from_sockaddr_in (NiceAddress *addr, struct sockaddr_in *sin) +{ + if (sin->sin_family == AF_INET6) + { + addr->type = NICE_ADDRESS_TYPE_IPV6; + nice_address_set_ipv6 (addr, + (gchar *) &((struct sockaddr_in6 *) sin)->sin6_addr); + } + else + { + addr->type = NICE_ADDRESS_TYPE_IPV4; + nice_address_set_ipv4 (addr, ntohl (sin->sin_addr.s_addr)); + } + + addr->port = ntohs (sin->sin_port); +} + + gchar * nice_address_to_string (NiceAddress *addr) { diff --git a/address/address.h b/address/address.h index fc7edd6..7f2b0f1 100644 --- a/address/address.h +++ b/address/address.h @@ -2,6 +2,8 @@ #ifndef _ADDRESS_H #define _ADDRESS_H +#include <netinet/in.h> + #include <glib.h> G_BEGIN_DECLS @@ -45,6 +47,9 @@ G_GNUC_WARN_UNUSED_RESULT gboolean nice_address_set_ipv4_from_string (NiceAddress *addr, const gchar *str); +void +nice_address_set_from_sockaddr_in (NiceAddress *addr, struct sockaddr_in *sin); + gboolean nice_address_equal (NiceAddress *a, NiceAddress *b); diff --git a/nice/libnice.symbols b/nice/libnice.symbols index 2e73228..71a0ff2 100644 --- a/nice/libnice.symbols +++ b/nice/libnice.symbols @@ -3,6 +3,7 @@ T nice_address_equal T nice_address_free T nice_address_is_private T nice_address_new +T nice_address_set_from_sockaddr_in T nice_address_set_ipv4 T nice_address_set_ipv4_from_string T nice_address_set_ipv6 |