repo: ngircd
action: commit
revision: 
path_from: 
revision_from: d5f80b2a8deda30d0dcd69bea81a3ca862cf46ca:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit d5f80b2a8deda30d0dcd69bea81a3ca862cf46ca
Author: Alexander Barton 
Date:   Mon Sep 14 00:25:48 2009 +0200

    Always use get{addr|name}info() when available

    Both getaddrinfo() and getnameinfo() are now used always when available, and
    not only when compiling ngIRCd with support for IPv6.

    This not only enables ngIRCd to handle multiple addresses per hostname when
    compiled without support for IPv6, but fixes binding ngIRCd to IP addresses
    on Mac OS X (and probably other BSD-based systems) as well: these systems
    require that sockaddr_in is zeroed out and sockaddr_in.sin_len is set to
    sizeof(sockaddr_in) like that:

      src/ipaddr/ng_ipaddr.c, line 54:

            assert(ip_str);
          + memset(addr, 0, sizeof *addr);
          + addr->sin4.sin_len = sizeof(addr->sin4);
            addr->sin4.sin_family = AF_INET;

    But this would break all the systems not using sockaddr_in.sin_len, for
    example Linux -- so we assume that all these systems provide getaddrinfo()
    and use that for now.

diff --git a/configure.in b/configure.in
index 1940834b0f0977a40776001d18c905a2f08ba5dd..
index ..567f216a7f1c21175693829ef4ec36300627fc1f 100644
--- a/configure.in
+++ b/configure.in
@@ -73,7 +73,6 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
   fi
 ])

-
 if test "$GCC" = "yes"; then
 	# We are using the GNU C compiler. Good!
 	CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
@@ -125,7 +124,6 @@ AC_TRY_COMPILE([
 AC_TYPE_SIGNAL
 AC_TYPE_SIZE_T

-
 # -- Libraries --

 AC_CHECK_LIB(UTIL,memmove)
@@ -141,7 +139,8 @@ AC_CHECK_FUNCS([ \
 	bind gethostbyaddr gethostbyname gethostname inet_ntoa \
 	setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))

-AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat strtok_r)
+AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
+ vsnprintf strdup strlcpy strlcat strtok_r)

 # -- Configuration options --

@@ -479,6 +478,8 @@ AC_ARG_ENABLE(ipv6,
 	if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
 )
 if test "$x_ipv6_on" = "yes"; then
+	# getaddrinfo() and getnameinfo() are optional when not compiling
+	# with IPv6 support, but are required for IPv6 to work!
 	AC_CHECK_FUNCS([ \
 		getaddrinfo getnameinfo \
 		],,AC_MSG_ERROR([required function missing for IPv6 support!]))

-----END OF PAGE-----