Commit c71d4f24 authored by Kai Vehmanen's avatar Kai Vehmanen

Updated local module to use the new address API.

darcs-hash:20070830070156-77cd4-c9cc192a0d40577c5d19af56bd22b479a0c6033e.gz
parent 8f3a86f9
...@@ -55,7 +55,7 @@ main (void) ...@@ -55,7 +55,7 @@ main (void)
NiceInterface *iface = i->data; NiceInterface *iface = i->data;
gchar addr[NICE_ADDRESS_STRING_LEN]; gchar addr[NICE_ADDRESS_STRING_LEN];
nice_address_to_string (&iface->addr, addr); nice_address_to_string (iface->addr, addr);
g_print ("%s: %s\n", iface->name, addr); g_print ("%s: %s\n", iface->name, addr);
nice_interface_free (iface); nice_interface_free (iface);
} }
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
# include "config.h" # include "config.h"
#endif #endif
#include <string.h>
#include <glib.h> #include <glib.h>
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -48,13 +50,27 @@ ...@@ -48,13 +50,27 @@
NICEAPI_EXPORT NiceInterface * NICEAPI_EXPORT NiceInterface *
nice_interface_new () nice_interface_new ()
{ {
return g_slice_new0 (NiceInterface); NiceInterface *iface;
NiceAddress *addr = nice_address_new ();
if (addr == NULL)
return NULL;
iface = g_slice_new0 (NiceInterface);
if (iface == NULL)
{
nice_address_free (addr);
return NULL;
}
iface->addr = addr;
return iface;
} }
NICEAPI_EXPORT void NICEAPI_EXPORT void
nice_interface_free (NiceInterface *iface) nice_interface_free (NiceInterface *iface)
{ {
g_free (iface->name); if (iface->addr != NULL)
nice_address_free (iface->addr);
g_slice_free (NiceInterface, iface); g_slice_free (NiceInterface, iface);
} }
...@@ -80,8 +96,9 @@ nice_list_local_interfaces () ...@@ -80,8 +96,9 @@ nice_list_local_interfaces ()
NiceInterface *iface; NiceInterface *iface;
iface = nice_interface_new (); iface = nice_interface_new ();
iface->name = g_strdup (i->ifa_name); strncpy (iface->name, i->ifa_name, sizeof (iface->name));
nice_address_set_from_sockaddr (&(iface->addr), addr); iface->name[sizeof (iface->name) - 1] = '\0';
nice_address_set_from_sockaddr (iface->addr, addr);
ret = g_slist_append (ret, iface); ret = g_slist_append (ret, iface);
} }
} }
......
...@@ -48,8 +48,8 @@ typedef struct _NiceInterface NiceInterface; ...@@ -48,8 +48,8 @@ typedef struct _NiceInterface NiceInterface;
struct _NiceInterface struct _NiceInterface
{ {
gchar *name; NiceAddress *addr;
NiceAddress addr; gchar name[16];
}; };
NiceInterface * NiceInterface *
......
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