Commit 394feb63 authored by Halton Huo's avatar Halton Huo Committed by Jonh Wendell
Browse files

Make code is compatible with diffrent ifaddrs structures

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.
parent b26e8061
......@@ -226,8 +226,23 @@ dnl *** Checks for ifaddrs.h ***
dnl ****************************
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])
#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 ])
......@@ -30,6 +30,12 @@
#include "if/ifaddrs.h"
#ifdef RFC2553
#define ADDR_FAMILY_MEMBER ss_family
#define ADDR_FAMILY_MEMBER sa_family
#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)
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;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment