Commit 236c4790 authored by Dafydd Harries's avatar Dafydd Harries

use NiceAddress for local interfaces

darcs-hash:20070207104150-c9803-1348829041d406702a91c55a60c0498e08c96a60.gz
parent e1fb5b09
include $(top_srcdir)/common.mk include $(top_srcdir)/common.mk
AM_CFLAGS = -Wall -Werror $(GLIB_CFLAGS) AM_CFLAGS = \
-Wall -Werror \
$(GLIB_CFLAGS) \
-I $(top_srcdir)/address
noinst_LTLIBRARIES = liblocal.la noinst_LTLIBRARIES = liblocal.la
...@@ -9,5 +12,8 @@ liblocal_la_SOURCES = local.h local.c ...@@ -9,5 +12,8 @@ liblocal_la_SOURCES = local.h local.c
noinst_PROGRAMS = list-local-interfaces noinst_PROGRAMS = list-local-interfaces
list_local_interfaces_LDADD = liblocal.la $(GLIB_LIBS) list_local_interfaces_LDADD = \
$(GLIB_LIBS) \
liblocal.la \
$(top_builddir)/address/libaddress.la
...@@ -12,13 +12,11 @@ main (void) ...@@ -12,13 +12,11 @@ main (void)
for (i = interfaces; i; i = i->next) for (i = interfaces; i; i = i->next)
{ {
NiceInterface *iface = i->data; NiceInterface *iface = i->data;
gchar *addr;
g_print ("%s: %d.%d.%d.%d\n", addr = nice_address_to_string (&iface->addr);
iface->name, g_print ("%s: %s\n", iface->name, addr);
(iface->addr & 0xff000000) >> 24, g_free (addr);
(iface->addr & 0x00ff0000) >> 16,
(iface->addr & 0x0000ff00) >> 8,
(iface->addr & 0x000000ff));
nice_interface_free (iface); nice_interface_free (iface);
} }
......
...@@ -58,8 +58,7 @@ nice_list_local_interfaces () ...@@ -58,8 +58,7 @@ nice_list_local_interfaces ()
iface->name = g_strdup (ifr->ifr_name); iface->name = g_strdup (ifr->ifr_name);
sin = (struct sockaddr_in *) &(ifr->ifr_addr); sin = (struct sockaddr_in *) &(ifr->ifr_addr);
iface->addr = (addr_ipv4) ntohl (sin->sin_addr.s_addr); nice_address_set_ipv4 (&iface->addr, ntohl (sin->sin_addr.s_addr));
ret = g_slist_append (ret, iface); ret = g_slist_append (ret, iface);
} }
......
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
#include <glib.h> #include <glib.h>
G_BEGIN_DECLS #include "address.h"
typedef guint32 addr_ipv4; G_BEGIN_DECLS
typedef struct _NiceInterface NiceInterface; typedef struct _NiceInterface NiceInterface;
struct _NiceInterface struct _NiceInterface
{ {
gchar *name; gchar *name;
addr_ipv4 addr; NiceAddress addr;
}; };
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