Commit ff52edd7 authored by Dafydd Harries's avatar Dafydd Harries

nice_address_set_from_sockaddr_in ()

darcs-hash:20070314141500-c9803-e5e719ce1a96d9c9a859913ee5554264c1218225.gz
parent 5912af5e
......@@ -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)
{
......
......@@ -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);
......
......@@ -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
......
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