mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-13 02:10:27 +00:00
Check for working getaddrinfo() function
At least AIX 4.3.3 and 5.1 have a broken implementation of getaddrinfo() which doesn't handle "0" as numeric service correctly. This patch adds a configure check for this case and changes all calling functions to only use getaddrinfo() if it "works". See <http://www.stacken.kth.se/lists/heimdal-discuss/2004-05/msg00059.html>
This commit is contained in:
parent
5a424f60da
commit
b8433e9261
35
configure.ng
35
configure.ng
@ -93,6 +93,35 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
|
|||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([WORKING_GETADDRINFO],[
|
||||||
|
AC_CHECK_FUNCS([getaddrinfo],[
|
||||||
|
AC_MSG_CHECKING([whether getaddrinfo() works])
|
||||||
|
AC_TRY_RUN([
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct addrinfo hints, *ai;
|
||||||
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_family = PF_UNSPEC;
|
||||||
|
if(getaddrinfo(NULL, "0", &hints, &ai) != 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
AC_DEFINE([HAVE_WORKING_GETADDRINFO], 1, [getaddrinfo(0)])
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
# -- Hard coded system and compiler dependencies/features/options ... --
|
# -- Hard coded system and compiler dependencies/features/options ... --
|
||||||
|
|
||||||
if test "$GCC" = "yes"; then
|
if test "$GCC" = "yes"; then
|
||||||
@ -189,11 +218,13 @@ AC_CHECK_FUNCS([ \
|
|||||||
AC_MSG_ERROR([required function missing!]))
|
AC_MSG_ERROR([required function missing!]))
|
||||||
|
|
||||||
# Optional functions
|
# Optional functions
|
||||||
AC_CHECK_FUNCS_ONCE([ \
|
AC_CHECK_FUNCS_ONCE([
|
||||||
arc4random arc4random_stir gai_strerror getaddrinfo getnameinfo inet_aton
|
arc4random arc4random_stir gai_strerror getnameinfo inet_aton \
|
||||||
sigaction sigprocmask snprintf vsnprintf strdup strndup strlcpy strlcat \
|
sigaction sigprocmask snprintf vsnprintf strdup strndup strlcpy strlcat \
|
||||||
strtok_r unsetenv waitpid])
|
strtok_r unsetenv waitpid])
|
||||||
|
|
||||||
|
WORKING_GETADDRINFO
|
||||||
|
|
||||||
# -- Configuration options --
|
# -- Configuration options --
|
||||||
|
|
||||||
# use syslog?
|
# use syslog?
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
GLOBAL bool
|
GLOBAL bool
|
||||||
ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
|
ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GETADDRINFO
|
#ifdef HAVE_WORKING_GETADDRINFO
|
||||||
int ret;
|
int ret;
|
||||||
char portstr[64];
|
char portstr[64];
|
||||||
struct addrinfo *res0;
|
struct addrinfo *res0;
|
||||||
|
@ -242,7 +242,7 @@ ForwardLookup(const char *hostname, array *IpAddr, int af)
|
|||||||
{
|
{
|
||||||
ng_ipaddr_t addr;
|
ng_ipaddr_t addr;
|
||||||
|
|
||||||
#ifdef HAVE_GETADDRINFO
|
#ifdef HAVE_WORKING_GETADDRINFO
|
||||||
int res;
|
int res;
|
||||||
struct addrinfo *a, *ai_results;
|
struct addrinfo *a, *ai_results;
|
||||||
static struct addrinfo hints;
|
static struct addrinfo hints;
|
||||||
|
Loading…
Reference in New Issue
Block a user