18719N/Acommit 010fe3b486610f3105d8756fb82aa315f7e54c40
18719N/AAuthor: Halton Huo <halton.huo@sun.com>
18719N/ADate: Thu May 6 15:29:02 2010 +0800
18719N/A Make code is compatible with diffrent ifaddrs strcucture
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@@ -331,13 +331,24 @@ AC_CHECK_FUNCS([gettimeofday])
18719N/A- ], have_getifaddrs=yes, have_getifaddrs=no)
18719N/A-AM_CONDITIONAL(HAVE_GETIFADDRS, [test "$have_getifaddrs" = "yes"])
18719N/A+AM_CONDITIONAL(SELF_IFADDRS, test "x$ac_cv_header_ifaddrs_h" != "xyes")
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+ if (myaddrs->ifa_addr->ss_family == AF_INET) {
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@@ -37,7 +37,7 @@ libvncserver_la_LIBADD = \
18719N/A+#define ADDR_FAMILY_MEMBER ss_family
18719N/A+#define ADDR_FAMILY_MEMBER sa_family
18719N/A #if defined(__linux__) && defined(NEED_TIMEVAL)
18719N/A@@ -621,7 +626,7 @@ ListenOnTCPPort(rfbScreenInfoPtr rfbScreen, int port, const char *netIface)
18719N/A if (ifa->ifa_addr == NULL || (ifa->ifa_flags & IFF_UP) == 0)
18719N/A- if (ifa->ifa_addr->sa_family == AF_INET) {
18719N/A+ if (ifa->ifa_addr->ADDR_FAMILY_MEMBER == AF_INET) {
18719N/A struct sockaddr_in *s4 = (struct sockaddr_in*)ifa->ifa_addr;
18719N/A@@ -635,11 +640,11 @@ ListenOnTCPPort(rfbScreenInfoPtr rfbScreen, int port, const char *netIface)
18719N/A- if (ifa->ifa_addr->sa_family == AF_INET6) {
18719N/A+ if (ifa->ifa_addr->ADDR_FAMILY_MEMBER == AF_INET6) {
18719N/A struct sockaddr_in6 *s6 = (struct sockaddr_in6*)ifa->ifa_addr;
18719N/A- if (inet_ntop(ifa->ifa_addr->sa_family, (struct sockaddr*)&s6->sin6_addr, buf, sizeof(buf)) == NULL) {
18719N/A+ if (inet_ntop(ifa->ifa_addr->ADDR_FAMILY_MEMBER, (struct sockaddr*)&s6->sin6_addr, buf, sizeof(buf)) == NULL) {
18719N/A rfbLog("%s: inet_ntop failed!\n", ifa->ifa_name);
18719N/A+#define ADDR_FAMILY_MEMBER ss_family
18719N/A+#define ADDR_FAMILY_MEMBER sa_family
18719N/A G_DEFINE_TYPE (VinoDBusListener, vino_dbus_listener, G_TYPE_OBJECT)
18719N/A@@ -126,7 +132,7 @@ get_local_hostname (VinoDBusListener *listener)
18719N/A if (ifa->ifa_addr == NULL || ifa->ifa_name == NULL || (ifa->ifa_flags & IFF_UP) == 0)
18719N/A- switch (ifa->ifa_addr->sa_family)
18719N/A+ switch (ifa->ifa_addr->ADDR_FAMILY_MEMBER)
18719N/A sin = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;