patches/vinagre-03-sol-ifaddrs.diff
author yippi
Mon, 27 Sep 2010 21:07:51 +0000
changeset 20108 51df67ca9307
parent 17968 1e83c4d58384
permissions -rw-r--r--
I had these modules listed as being owned by me, but they are really owned by wangke, correcting.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17968
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     1
commit 2f230c0bf425bc5767d36c4c06672428da35244c
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     2
Author: Halton Huo <[email protected]>
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     3
Date:   Thu May 6 16:03:20 2010 +0800
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     4
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     5
    Make code is compatible with diffrent ifaddrs strcucture
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     6
    
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     7
    OpenSolaris (after b137) uses "struct sockaddr_storage", not "struct sockaddr"
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     8
    for ifa_addr member of "struct ifaddrs". This is followed RFC2553. Before
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
     9
    BSD and Linux systems move to follow RFC2553, the codes need to be compiled
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    10
    under both cases.
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    11
    
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    12
    https://bugzilla.gnome.org/show_bug.cgi?id=617862
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    13
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    14
diff --git a/configure.ac b/configure.ac
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    15
index 5d4000f..33e097f 100644
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    16
--- a/configure.ac
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    17
+++ b/configure.ac
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    18
@@ -224,8 +224,23 @@ dnl *** Checks for ifaddrs.h ***
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    19
 dnl ****************************
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    20
 AC_CHECK_HEADER(ifaddrs.h)
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    21
 AM_CONDITIONAL(SELF_IFADDRS, test "x$ac_cv_header_ifaddrs_h" != "xyes")
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    22
+
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    23
+dnl RFC2553 introduce sockaddr_storage as ifa_addr member in ifaddrs structure
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    24
+dnl Not all distros follow this.
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    25
 if test "x$ac_cv_header_ifaddrs_h" = "xyes"; then
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    26
-  AC_DEFINE(HAVE_IFADDRS_H, [1], [Define if we have system ifaddrs.h])
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    27
+        AC_DEFINE(HAVE_IFADDRS_H, [1], [Define if we have system ifaddrs.h])
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    28
+        AC_TRY_COMPILE([
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    29
+          #include <ifaddrs.h>
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    30
+          #include <net/if.h>
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    31
+          ],[
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    32
+          struct ifaddrs *myaddrs;
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    33
+          getifaddrs (&myaddrs);
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    34
+          if (myaddrs->ifa_addr->ss_family == AF_INET) {
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    35
+          }
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    36
+        ], have_sockaddr_storage=yes, have_sockaddr_storage=no)
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    37
+        if test "x$have_sockaddr_storage" = "xyes"; then
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    38
+           AC_DEFINE(RFC2553, [], [Define to if follow RFC2553 ])
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    39
+        fi
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    40
 fi
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    41
 
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    42
 
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    43
diff --git a/plugins/vnc/vinagre-vnc-listener-dialog.c b/plugins/vnc/vinagre-vnc-listener-dialog.c
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    44
index 6da6902..46fff70 100644
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    45
--- a/plugins/vnc/vinagre-vnc-listener-dialog.c
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    46
+++ b/plugins/vnc/vinagre-vnc-listener-dialog.c
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    47
@@ -30,6 +30,12 @@
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    48
 #include "if/ifaddrs.h"
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    49
 #endif
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    50
 
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    51
+#ifdef RFC2553
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    52
+#define ADDR_FAMILY_MEMBER ss_family
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    53
+#else
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    54
+#define ADDR_FAMILY_MEMBER sa_family
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    55
+#endif
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    56
+
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    57
 #include <string.h>
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    58
 #include <glib/gi18n.h>
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    59
 
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    60
@@ -69,7 +75,7 @@ setup_ip_buffer (VncListenDialog *dialog)
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    61
       if (ifa->ifa_addr == NULL || ifa->ifa_name == NULL || (ifa->ifa_flags & IFF_UP) == 0 || strncmp (ifa->ifa_name, "lo", 2) == 0)
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    62
 	continue;
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    63
 
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    64
-      switch (ifa->ifa_addr->sa_family)
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    65
+      switch (ifa->ifa_addr->ADDR_FAMILY_MEMBER)
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    66
 	{
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    67
 	  case AF_INET:
1e83c4d58384 2010-05-06 Halton Huo <[email protected]>
halton
parents:
diff changeset
    68
 	    sin = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;