Another stab at getting ss_family happy on older glibc

--HG--
extra : convert_revision : 7a1e9b08a576d794c28275e1bf54cb603372a4a6
This commit is contained in:
Matt Johnston 2006-06-12 15:57:14 +00:00
parent d0537c7506
commit ac2b546a13
3 changed files with 10 additions and 9 deletions

View File

@ -342,7 +342,7 @@ AC_CHECK_MEMBERS([struct utmp.ut_host, struct utmp.ut_pid, struct utmp.ut_type,
#endif #endif
]) ])
AC_CHECK_MEMBERS([struct utmpx.ut_host, struct utmpx.ut_syslen, struct utmpx.ut_type, struct utmpx.ut_id, struct utmpx.ut_addr, struct utmpx.ut_addr_v6, struct utmpx.ut_time, struct utmpx.ut_tv, struct sockaddr_storage.ss_family, struct sockadd_storage.__family],,,[ AC_CHECK_MEMBERS([struct utmpx.ut_host, struct utmpx.ut_syslen, struct utmpx.ut_type, struct utmpx.ut_id, struct utmpx.ut_addr, struct utmpx.ut_addr_v6, struct utmpx.ut_time, struct utmpx.ut_tv],,,[
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#if HAVE_UTMPX_H #if HAVE_UTMPX_H
@ -350,6 +350,8 @@ AC_CHECK_MEMBERS([struct utmpx.ut_host, struct utmpx.ut_syslen, struct utmpx.ut_
#endif #endif
]) ])
AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],,,[])
AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent) AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
AC_CHECK_FUNCS(utmpname) AC_CHECK_FUNCS(utmpname)
AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline ) AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )

View File

@ -400,7 +400,10 @@ unsigned char * getaddrstring(struct sockaddr_storage* addr, int withport) {
len = sizeof(struct sockaddr_storage); len = sizeof(struct sockaddr_storage);
/* Some platforms such as Solaris 8 require that len is the length /* Some platforms such as Solaris 8 require that len is the length
* of the specific structure. */ * of the specific structure. Some older linux systems (glibc 2.1.3
* such as debian potato) have sockaddr_storage.__ss_family instead
* but we'll ignore them */
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
if (addr->ss_family == AF_INET) { if (addr->ss_family == AF_INET) {
len = sizeof(struct sockaddr_in); len = sizeof(struct sockaddr_in);
} }
@ -408,6 +411,7 @@ unsigned char * getaddrstring(struct sockaddr_storage* addr, int withport) {
if (addr->ss_family == AF_INET6) { if (addr->ss_family == AF_INET6) {
len = sizeof(struct sockaddr_in6); len = sizeof(struct sockaddr_in6);
} }
#endif
#endif #endif
ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
@ -448,6 +452,7 @@ char* getaddrhostname(struct sockaddr_storage * addr) {
len = sizeof(struct sockaddr_storage); len = sizeof(struct sockaddr_storage);
/* Some platforms such as Solaris 8 require that len is the length /* Some platforms such as Solaris 8 require that len is the length
* of the specific structure. */ * of the specific structure. */
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
if (addr->ss_family == AF_INET) { if (addr->ss_family == AF_INET) {
len = sizeof(struct sockaddr_in); len = sizeof(struct sockaddr_in);
} }
@ -456,6 +461,7 @@ char* getaddrhostname(struct sockaddr_storage * addr) {
len = sizeof(struct sockaddr_in6); len = sizeof(struct sockaddr_in6);
} }
#endif #endif
#endif
ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),

View File

@ -135,13 +135,6 @@ typedef u_int16_t uint16_t;
#define LOG_AUTHPRIV LOG_AUTH #define LOG_AUTHPRIV LOG_AUTH
#endif #endif
/* glibc 2.1.3 systems have sockaddr_storage.__ss_family rather than
* sockaddr_storage.ss_family */
#if !defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) \
&& defined(HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY)
#define ss_family __ss_family
#endif
/* so we can avoid warnings about unused params (ie in signal handlers etc) */ /* so we can avoid warnings about unused params (ie in signal handlers etc) */
#ifdef UNUSED #ifdef UNUSED
#elif defined(__GNUC__) #elif defined(__GNUC__)