commit 2f230c0bf425bc5767d36c4c06672428da35244c
Author: Halton Huo <halton.huo@sun.com>
Date: Thu May 6 16:03:20 2010 +0800
Make code is compatible with diffrent ifaddrs strcucture
OpenSolaris (after b137) uses "struct sockaddr_storage", not "struct sockaddr"
for ifa_addr member of "struct ifaddrs". This is followed RFC2553. Before
BSD and Linux systems move to follow RFC2553, the codes need to be compiled
under both cases.
https://bugzilla.gnome.org/show_bug.cgi?id=617862
diff --git a/configure.ac b/configure.ac
index 5d4000f..33e097f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -224,8 +224,23 @@ dnl *** Checks for ifaddrs.h ***
dnl ****************************
AC_CHECK_HEADER(ifaddrs.h)
AM_CONDITIONAL(SELF_IFADDRS, test "x$ac_cv_header_ifaddrs_h" != "xyes")
+
+dnl RFC2553 introduce sockaddr_storage as ifa_addr member in ifaddrs structure
+dnl Not all distros follow this.
if test "x$ac_cv_header_ifaddrs_h" = "xyes"; then
- AC_DEFINE(HAVE_IFADDRS_H, [1], [Define if we have system ifaddrs.h])
+ AC_DEFINE(HAVE_IFADDRS_H, [1], [Define if we have system ifaddrs.h])
+ AC_TRY_COMPILE([
+ #include <ifaddrs.h>
+ #include <net/if.h>
+ ],[
+ struct ifaddrs *myaddrs;
+ getifaddrs (&myaddrs);
+ if (myaddrs->ifa_addr->ss_family == AF_INET) {
+ }
+ ], have_sockaddr_storage=yes, have_sockaddr_storage=no)
+ if test "x$have_sockaddr_storage" = "xyes"; then
+ AC_DEFINE(RFC2553, [], [Define to if follow RFC2553 ])
+ fi
fi
diff --git a/plugins/vnc/vinagre-vnc-listener-dialog.c b/plugins/vnc/vinagre-vnc-listener-dialog.c
index 6da6902..46fff70 100644
--- a/plugins/vnc/vinagre-vnc-listener-dialog.c
+++ b/plugins/vnc/vinagre-vnc-listener-dialog.c
@@ -30,6 +30,12 @@
#include "if/ifaddrs.h"
#endif
+#ifdef RFC2553
+#define ADDR_FAMILY_MEMBER ss_family
+#else
+#define ADDR_FAMILY_MEMBER sa_family
+#endif
+
#include <string.h>
#include <glib/gi18n.h>
@@ -69,7 +75,7 @@ setup_ip_buffer (VncListenDialog *dialog)
if (ifa->ifa_addr == NULL || ifa->ifa_name == NULL || (ifa->ifa_flags & IFF_UP) == 0 || strncmp (ifa->ifa_name, "lo", 2) == 0)
continue;
- switch (ifa->ifa_addr->sa_family)
+ switch (ifa->ifa_addr->ADDR_FAMILY_MEMBER)
{
case AF_INET:
sin = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;