Commit f37d8947 authored by Kai Vehmanen's avatar Kai Vehmanen
Browse files

Updated test coverage of local submodule. Added NICEAPI_EXPORT attributes....

Updated test coverage of local submodule. Added NICEAPI_EXPORT attributes. Fixed bugs in handling error cases with getifaddrs()

darcs-hash:20070619075609-77cd4-b3cd9ca9dc1c41a501d3a9381fea337099101fc9.gz
parent 99d3616c
......@@ -17,7 +17,10 @@ noinst_LTLIBRARIES = liblocal.la
liblocal_la_SOURCES = local.h local.c
pkginclude_HEADERS = local.h
noinst_PROGRAMS = list-local-interfaces
TESTS = list-local-interfaces
list_local_interfaces_LDADD = \
$(GLIB_LIBS) \
......
......@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "local.h"
......@@ -45,6 +48,8 @@ main (void)
interfaces = nice_list_local_interfaces ();
g_assert (interfaces);
for (i = interfaces; i; i = i->next)
{
NiceInterface *iface = i->data;
......
......@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib.h>
......@@ -42,20 +45,20 @@
#include "local.h"
NiceInterface *
NICEAPI_EXPORT NiceInterface *
nice_interface_new ()
{
return g_slice_new0 (NiceInterface);
}
void
NICEAPI_EXPORT void
nice_interface_free (NiceInterface *iface)
{
g_free (iface->name);
g_slice_free (NiceInterface, iface);
}
GSList *
NICEAPI_EXPORT GSList *
nice_list_local_interfaces ()
{
GSList *ret = NULL;
......@@ -66,17 +69,19 @@ nice_list_local_interfaces ()
for (i = ifs; i; i = i->ifa_next)
{
struct sockaddr_in *addr;
const struct sockaddr *addr;
addr = (struct sockaddr_in *) i->ifa_addr;
addr = (struct sockaddr *) i->ifa_addr;
if (addr == NULL)
continue; /* interface with no address */
if (addr->sin_family == AF_INET || addr->sin_family == AF_INET6)
if (addr->sa_family == AF_INET || addr->sa_family == AF_INET6)
{
NiceInterface *iface;
iface = g_slice_new0 (NiceInterface);
iface = nice_interface_new ();
iface->name = g_strdup (i->ifa_name);
nice_address_set_from_sockaddr (&(iface->addr), (const struct sockaddr *)addr);
nice_address_set_from_sockaddr (&(iface->addr), addr);
ret = g_slist_append (ret, iface);
}
}
......
Supports Markdown
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