]> git.sesse.net Git - vlc/commitdiff
* ./configure.in, ./plugins/network/ipv6.c: support for the GNU glibc
authorSam Hocevar <sam@videolan.org>
Thu, 18 Apr 2002 04:34:37 +0000 (04:34 +0000)
committerSam Hocevar <sam@videolan.org>
Thu, 18 Apr 2002 04:34:37 +0000 (04:34 +0000)
    extension gethostbyname2(), thanks to Thomas Graf.

configure
configure.in
include/defs.h.in
plugins/network/ipv6.c

index 54323d2b493541563272378e0b8aa4f1dd213dca..2043216486ba3c939a4d76745a312a5caf8f9b32 100755 (executable)
--- a/configure
+++ b/configure
@@ -3270,7 +3270,7 @@ fi
 
 save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"
 
-for ac_func in gettimeofday select strerror strtod strtol isatty usleep vasprintf swab sigrelse getpwuid memalign posix_memalign
+for ac_func in gettimeofday select strerror strtod strtol isatty usleep vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:3277: checking for $ac_func" >&5
index 9067c0c205325180dab143c8c3822d6d9ff87ec6..4df749cb007a0854a680fb6cfabe26a22c4edfa2 100644 (file)
@@ -111,7 +111,7 @@ dnl The -DSYS_FOO flag
 save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"
 
 dnl Check for system libs needed
-AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty usleep vasprintf swab sigrelse getpwuid memalign posix_memalign)
+AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty usleep vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2)
 
 AC_CHECK_FUNC(connect,,[
   AC_CHECK_LIB(socket,connect,
index aba5b386d79dde51fd8611e814c8a5f4d0bcd9cc..e08b552a682158dd5bc921b83e8a0f70728ff759 100644 (file)
@@ -76,6 +76,9 @@
 /* Define if you have the getgid function.  */
 #undef HAVE_GETGID
 
+/* Define if you have the gethostbyname2 function.  */
+#undef HAVE_GETHOSTBYNAME2
+
 /* Define if you have the getpagesize function.  */
 #undef HAVE_GETPAGESIZE
 
index 808caa236613dd66797723afbfd279bcd2a8894b..6a337240d538ec610722fdda250a99a092696e81 100644 (file)
@@ -2,7 +2,7 @@
  * ipv6.c: IPv6 network abstraction layer
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: ipv6.c,v 1.3 2002/03/15 04:41:54 sam Exp $
+ * $Id: ipv6.c,v 1.4 2002/04/18 04:34:37 sam Exp $
  *
  * Authors: Alexis Guillard <alexis.guillard@bt.com>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -108,18 +108,34 @@ static int BuildAddr( struct sockaddr_in6 * p_socket,
     {
         p_socket->sin6_addr = in6addr_any;
     }
-    else if( *psz_address != '['
-              || psz_address[strlen(psz_address) - 1] != ']' )
-    {
-        intf_ErrMsg( "ipv6: IPv6 address is invalid, discarding" );
-        return( -1 );
-    } 
-    else
+    else if( psz_address[0] == '['
+              && psz_address[strlen(psz_address) - 1] == ']' )
     {
         psz_address++;
         psz_address[strlen(psz_address) - 1] = '\0' ;
         inet_pton(AF_INET6, psz_address, &p_socket->sin6_addr.s6_addr); 
     }
+    else
+    {
+#ifdef HAVE_GETHOSTBYNAME2
+        struct hostent    * p_hostent;
+
+        /* We have a fqdn, try to find its address */
+        if ( (p_hostent = gethostbyname2( psz_address, AF_INET6 )) == NULL )
+        {
+            intf_ErrMsg( "ipv6 error: unknown host %s", psz_address );
+            return( -1 );
+        }
+
+        /* Copy the first address of the host in the socket address */
+        memcpy( &p_socket->sin6_addr, p_hostent->h_addr_list[0],
+                 p_hostent->h_length );
+#else
+        intf_ErrMsg( "ipv6 error: IPv6 address %s is invalid", psz_address );
+        return( -1 );
+#endif
+    }
+
     return( 0 );
 }