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