1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-18 04:51:52 +00:00

Restructure network tests: Always check for both inet_aton and inet_pton.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28439 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
diego 2009-02-01 14:38:28 +00:00
parent 0d86a0f652
commit 7e1662839a
4 changed files with 37 additions and 53 deletions

48
configure vendored
View File

@ -2915,59 +2915,49 @@ else
fi fi
_use_aton=no
echocheck "inet_pton()" echocheck "inet_pton()"
def_inet_pton='#define HAVE_INET_PTON 0'
inet_pton=no
cat > $TMPC << EOF cat > $TMPC << EOF
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
int main(void) { (void) inet_pton(0, 0, 0); return 0; } int main(void) { (void) inet_pton(0, 0, 0); return 0; }
EOF EOF
if test "$_winsock2_h" = yes ; then if cc_check $_ld_sock ; then
_res_comment="using winsock2 functions instead"
echores "no"
elif cc_check $_ld_sock ; then
# NOTE: Linux has libresolv but does not need it # NOTE: Linux has libresolv but does not need it
:
test $_ld_sock && _res_comment="using $_ld_sock" test $_ld_sock && _res_comment="using $_ld_sock"
echores "yes" inet_pton=yes
def_inet_pton='#define HAVE_INET_PTON 1'
elif cc_check $_ld_sock -lresolv ; then elif cc_check $_ld_sock -lresolv ; then
# NOTE: needed for SunOS at least
_ld_sock="$_ld_sock -lresolv" _ld_sock="$_ld_sock -lresolv"
_res_comment="using $_ld_sock" _res_comment="using $_ld_sock"
echores "yes" inet_pton=yes
else def_inet_pton='#define HAVE_INET_PTON 1'
_res_comment="trying inet_aton next" fi
echores "no" echores "$inet_pton"
echocheck "inet_aton()" echocheck "inet_aton()"
def_inet_aton='#define HAVE_INET_ATON 0'
inet_aton=no
cat > $TMPC << EOF cat > $TMPC << EOF
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
int main(void) { (void) inet_aton(0, 0); return 0; } int main(void) { (void) inet_aton(0, 0); return 0; }
EOF EOF
_use_aton=yes
if cc_check $_ld_sock ; then if cc_check $_ld_sock ; then
# NOTE: Linux has libresolv but does not need it # NOTE: Linux has libresolv but does not need it
:
test $_ld_sock && _res_comment="using $_ld_sock" test $_ld_sock && _res_comment="using $_ld_sock"
def_inet_aton='#define HAVE_INET_ATON 1'
inet_aton=yes
elif cc_check $_ld_sock -lresolv ; then elif cc_check $_ld_sock -lresolv ; then
# NOTE: needed for SunOS at least
_ld_sock="$_ld_sock -lresolv" _ld_sock="$_ld_sock -lresolv"
_res_comment="using $_ld_sock" _res_comment="using $_ld_sock"
else def_inet_aton='#define HAVE_INET_ATON 1'
_use_aton=no inet_aton=yes
_network=no
_res_comment="network support disabled"
fi fi
echores "$_use_aton" echores "$inet_aton"
fi
_def_inet_aton='#define HAVE_INET_ATON 0'
if test "$_use_aton" = yes; then
_def_inet_aton='#define HAVE_INET_ATON 1'
fi
echocheck "socklen_t" echocheck "socklen_t"
@ -3003,7 +2993,8 @@ echores "$_closesocket"
echocheck "network" echocheck "network"
# FIXME network check test $_winsock2_h = no && test $inet_pton = no &&
test $inet_aton = no && _network=no
if test "$_network" = yes ; then if test "$_network" = yes ; then
_def_network='#define CONFIG_NETWORK 1' _def_network='#define CONFIG_NETWORK 1'
_ld_extra="$_ld_extra $_ld_sock" _ld_extra="$_ld_extra $_ld_sock"
@ -8483,7 +8474,8 @@ $_def_fribidi
$_def_closesocket $_def_closesocket
$_def_ftp $_def_ftp
$_def_inet6 $_def_inet6
$_def_inet_aton $def_inet_aton
$def_inet_pton
$_def_live $_def_live
$_def_nemesi $_def_nemesi
$_def_network $_def_network

View File

@ -297,13 +297,11 @@ rtp_connect (char *hostname, int port)
if (!hostname || !strcmp (hostname, "0.0.0.0")) if (!hostname || !strcmp (hostname, "0.0.0.0"))
sin.sin_addr.s_addr = htonl (INADDR_ANY); sin.sin_addr.s_addr = htonl (INADDR_ANY);
else else
#if !HAVE_WINSOCK2_H #if HAVE_INET_PTON
#if HAVE_INET_ATON
inet_aton (hostname, &sin.sin_addr);
#else
inet_pton (AF_INET, hostname, &sin.sin_addr); inet_pton (AF_INET, hostname, &sin.sin_addr);
#endif #elif HAVE_INET_ATON
#else inet_aton (hostname, &sin.sin_addr);
#elif HAVE_WINSOCK2_H
sin.sin_addr.s_addr = htonl (INADDR_ANY); sin.sin_addr.s_addr = htonl (INADDR_ANY);
#endif #endif
sin.sin_port = htons (port); sin.sin_port = htons (port);
@ -386,13 +384,11 @@ is_multicast_address (char *addr)
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
#if !HAVE_WINSOCK2_H #if HAVE_INET_PTON
#if HAVE_INET_ATON
inet_aton (addr, &sin.sin_addr);
#else
inet_pton (AF_INET, addr, &sin.sin_addr); inet_pton (AF_INET, addr, &sin.sin_addr);
#endif #elif HAVE_INET_ATON
#else inet_aton (addr, &sin.sin_addr);
#elif HAVE_WINSOCK2_H
sin.sin_addr.s_addr = htonl (INADDR_ANY); sin.sin_addr.s_addr = htonl (INADDR_ANY);
#endif #endif

View File

@ -115,13 +115,11 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
memset(&server_address, 0, sizeof(server_address)); memset(&server_address, 0, sizeof(server_address));
#if !HAVE_WINSOCK2_H #if HAVE_INET_PTON
#if HAVE_INET_ATON
if (inet_aton(host, our_s_addr)!=1)
#else
if (inet_pton(af, host, our_s_addr)!=1) if (inet_pton(af, host, our_s_addr)!=1)
#endif #elif HAVE_INET_ATON
#else if (inet_aton(host, our_s_addr)!=1)
#elif HAVE_WINSOCK2_H
if ( inet_addr(host)==INADDR_NONE ) if ( inet_addr(host)==INADDR_NONE )
#endif #endif
{ {

View File

@ -91,15 +91,13 @@ udp_open_socket (URL_t *url)
} }
else else
{ {
#if !HAVE_WINSOCK2_H #if HAVE_INET_PTON
#if HAVE_INET_ATON
inet_aton (url->hostname, &server_address.sin_addr);
#else
inet_pton (AF_INET, url->hostname, &server_address.sin_addr); inet_pton (AF_INET, url->hostname, &server_address.sin_addr);
#endif /* HAVE_INET_ATON */ #elif HAVE_INET_ATON
#else inet_aton (url->hostname, &server_address.sin_addr);
#elif !HAVE_WINSOCK2_H
server_address.sin_addr.s_addr = htonl(INADDR_ANY); server_address.sin_addr.s_addr = htonl(INADDR_ANY);
#endif /* HAVE_WINSOCK2_H */ #endif
} }
server_address.sin_family = AF_INET; server_address.sin_family = AF_INET;
server_address.sin_port = htons (url->port); server_address.sin_port = htons (url->port);