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