GNOME Bugzilla – Bug 617848
Fail to compile with system ifaddrs after OpenSolaris b137
Last modified: 2010-06-21 20:52:01 UTC
After http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6731945 is fixed into OpenSolaris b137, the vino code use the system ifaddrs API instead. But it fails to compile: [...] source='sockets.c' object='sockets.lo' libtool=yes \ DEPDIR=.deps depmode=none /bin/bash ../../depcomp \ /bin/bash ../../libtool --tag=CC --mode=compile /opt/SunStudioExpress/bin/cc -DHAVE_CONFIG_H -I. -I../.. -g -c -o sockets.lo sockets.c /opt/SunStudioExpress/bin/cc -DHAVE_CONFIG_H -I. -I../.. -g -c sockets.c -KPIC -DPIC -o .libs/sockets.o "sockets.c", line 624: improper member use: sa_family "sockets.c", line 638: improper member use: sa_family "sockets.c", line 642: improper member use: sa_family cc: acomp failed for sockets.c [...]
The reason is that the type of ifa_addr member of "struct ifaddrs" is "struct sockaddr_storage", not "struct sockaddr". The latter one is common in BSD like and Linux system. Please refer to http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/head/ifaddrs.h#38. After talked with the Solaris engineer, he explained as below: The ifaddrs structure in BSD and Linux were introduced before the introduction of sockaddr_storage by RFC2553. That is why I think they were never changed to use sockaddr_storage. But the getifaddrs in Solaris is new and we used sockaddr_storage as recommended by the RFC. Before BSD and Linux convert to use RFC2553, it is durable for top applications themselves to workable with both cases with below likely patch. #ifdef RFC2553 ifa->ifa_addr->ss_family #else ifa->ifa_addr->sa_family #endif Here RFC2553 is defined during configure time if "struct ifaddrs" use "struct sockaddr_storage" rather than "struct sockaddr".
Created attachment 160402 [details] [review] Make code is compatible with diffrent ifaddrs strcucture As described in comment #1, I work out this patch. Rather than using lots of "#ifdef..#else..#endif" in code, I use ADDR_FAMILY_MEMBER for different address family member name. This patch is tested under OpenSolaris b128 and Ubuntu 10.04. Please review.
Thanks, Halton, patch pushed.