*** xine-lib-1-rc0a/src/input/input_http.c	Wed Sep 24 08:58:56 2003
--- xine-lib-1-rc0a-patched/src/input/input_http.c	Wed Sep 24 08:59:21 2003
***************
--- 205,236 ----
    } else
      if (host != NULL)
        *host = start;
! 
! #ifdef ENABLE_IPV6
!   // Add support for RFC 2732
!   {
!       char *hostbracket, *hostendbracket;
! 
!       hostbracket = strchr(start, '[');
!       if (hostbracket != NULL) {
! 	  
! 	  hostendbracket = strchr(hostbracket, ']');
! 	  
! 	  if (hostendbracket != NULL) {
! 	      
! 	      *hostendbracket = '\0';
! 	      *host = (hostbracket + 1);
! 	      
! 	      // Might have a trailing port
! 	      
! 	      if (*(hostendbracket+1) == ':') {
! 		  portcolon = (hostendbracket + 1);
! 	      }
! 	  }
!       }
!   }
! #endif
! 
    if (slash != 0)
    {
      *slash = '\0';
*** xine-lib-1-rc0a/src/input/input_net.c	Sun Jul 13 21:29:04 2003
--- xine-lib-1-rc0a-patched/src/input/input_net.c	Wed Sep 24 09:05:33 2003
***************
*** 49,54 ****
--- 49,59 ----
  #include <sys/socket.h>
  #include <netinet/in.h>
  
+ #ifdef ENABLE_IPV6
+ #include <sys/types.h>
+ #include <netdb.h>
+ #endif
+ 
  #ifndef WIN32
  #include <arpa/inet.h>
  #include <netdb.h>
***************
*** 104,110 ****
  /*                       Private functions                          */
  /* **************************************************************** */
  
! static int host_connect_attempt(struct in_addr ia, int port, xine_t *xine) {
  
    int                s;
    struct sockaddr_in sin;
--- 109,115 ----
  /*                       Private functions                          */
  /* **************************************************************** */
  
! static int host_connect_attempt_ipv4(struct in_addr ia, int port, xine_t *xine) {
  
    int                s;
    struct sockaddr_in sin;
***************
*** 135,141 ****
    return s;
  }
  
! static int host_connect(const char *host, int port, xine_t *xine) {
    struct hostent *h;
    int             i;
    int             s;
--- 140,172 ----
    return s;
  }
  
! static int host_connect_attempt(int family, struct sockaddr* sin, int addrlen, xine_t *xine) {
! 
!   int                s;
!   
!   s = socket(family, SOCK_STREAM, IPPROTO_TCP);
!   if (s==-1) {
!     xine_log (xine, XINE_LOG_MSG,
! 	      _("input_net: socket(): %s\n"), strerror(errno));
!     return -1;
!   }
! 
! #ifndef WIN32
!   if (connect(s, sin, addrlen)==-1 && errno != EINPROGRESS)  
! #else
!   if (connect(s, sin, addrlen)==-1 && WSAGetLastError() != WSAEINPROGRESS) 
! #endif
!   {
!     xine_log (xine, XINE_LOG_MSG,
! 	      _("input_net: connect(): %s\n"), strerror(errno));
!     close(s);
!     return -1;
!   }	
! 
!   return s;
! }
! 
! static int host_connect_ipv4(const char *host, int port, xine_t *xine) {
    struct hostent *h;
    int             i;
    int             s;
***************
*** 150,156 ****
    for (i=0; h->h_addr_list[i]; i++) {
      struct in_addr ia;
      memcpy (&ia, h->h_addr_list[i],4);
!     s = host_connect_attempt (ia, port, xine);
      if (s != -1)
        return s;
    }
--- 181,187 ----
    for (i=0; h->h_addr_list[i]; i++) {
      struct in_addr ia;
      memcpy (&ia, h->h_addr_list[i],4);
!     s = host_connect_attempt_ipv4 (ia, port, xine);
      if (s != -1)
        return s;
    }
***************
*** 160,165 ****
--- 191,247 ----
    return -1;
  }
  
+ static int host_connect(const char *host, int port, xine_t *xine) {
+ 
+ #ifndef ENABLE_IPV6
+     return host_connect_ipv4(host, port, xine);
+ #else
+ 
+   struct addrinfo hints, *res, *tmpaddr;
+   int error;
+   char strport[16];
+   int             i;
+   int             s;
+ 	
+   memset(&hints, 0, sizeof(hints));
+   hints.ai_socktype = SOCK_STREAM;
+   hints.ai_family = PF_UNSPEC; 
+   
+   snprintf(strport, sizeof(strport), "%d", port);
+ 
+ #ifdef LOG  
+   printf("Resolving host '%s' at port '%s'\n", host, strport);
+ #endif
+ 
+   error = getaddrinfo(host, strport, &hints, &res);
+   
+   if (error) {
+       
+     xine_log (xine, XINE_LOG_MSG,
+ 	      _("input_net: unable to resolve '%s'.\n"), host);
+     return -1;
+   }
+   
+   // We loop over all addresses and try to connect
+   tmpaddr = res;
+   while (tmpaddr) {
+       
+       s = host_connect_attempt (tmpaddr->ai_family, 
+ 				tmpaddr->ai_addr, tmpaddr->ai_addrlen, xine);
+       if (s != -1)
+ 	  return s;
+ 
+       tmpaddr = tmpaddr->ai_next;
+   }
+   
+   xine_log (xine, XINE_LOG_MSG,
+ 	    _("input_net: unable to connect to '%s'.\n"), host);
+   return -1;
+ 
+ #endif
+ 
+ }
+ 
  #define LOW_WATER_MARK  50
  #define HIGH_WATER_MARK 100
  
*** xine-lib-1-rc0a/src/xine-engine/io_helper.c	Sun Jul 27 18:42:56 2003
--- xine-lib-1-rc0a-patched/src/xine-engine/io_helper.c	Wed Sep 24 09:12:57 2003
***************
*** 45,51 ****
  #define XIO_POLLING_INTERVAL  50000  /* usec */
  
  
! int xio_tcp_connect(xine_stream_t *stream, const char *host, int port) {
  
    struct hostent *h;
    int             i, s;
--- 45,51 ----
  #define XIO_POLLING_INTERVAL  50000  /* usec */
  
  
! int xio_tcp_connect_ipv4(xine_stream_t *stream, const char *host, int port) {
  
    struct hostent *h;
    int             i, s;
***************
*** 107,112 ****
--- 107,188 ----
    return -1;
  }
  
+ int xio_tcp_connect(xine_stream_t *stream, const char *host, int port) {
+ 
+ #ifndef ENABLE_IPV6
+     return xio_tcp_connect_ipv4(stream, host, port);
+ #else
+   int             s;
+   struct addrinfo hints, *res, *tmpaddr;
+   int error;
+   char strport[16];
+ 	
+   memset(&hints, 0, sizeof(hints));
+   hints.ai_socktype = SOCK_STREAM;
+   hints.ai_family = PF_UNSPEC; 
+ 
+   snprintf(strport, sizeof(strport), "%d", port);
+   
+   printf("Resolving host '%s' at port '%s'\n", host, strport);
+ 
+   error = getaddrinfo(host, strport, &hints, &res);
+ 
+   if (error) {
+     xine_message(stream, XINE_MSG_UNKNOWN_HOST, 
+ 		 "unable to resolve", host, NULL);
+     return -1;
+   }
+ 
+   tmpaddr = res;
+ 
+   while (tmpaddr) {
+       
+       s = socket(tmpaddr->ai_family, SOCK_STREAM, IPPROTO_TCP);  
+       if (s == -1) {
+ 	  xine_message(stream, XINE_MSG_CONNECTION_REFUSED, 
+ 		       "failed to create socket", strerror(errno), NULL);
+ 	  tmpaddr = tmpaddr->ai_next;
+ 	  continue;
+       }
+ 
+       /**
+        * Uncommenting nonblocking features due to IPv6 support.
+        * Need to know if the connect failed, in order to try another
+        * address (if available).  Error will be reported if no address
+        * worked.
+        */
+ 
+ #ifndef WIN32
+ 
+     if (connect(s, tmpaddr->ai_addr, 
+ 		tmpaddr->ai_addrlen)==-1 && errno != EINPROGRESS) {
+ 	
+ #else
+     if (connect(s, tmpaddr->ai_addr, 
+ 		tmpaddr->ai_addrlen)==-1 && 
+ 	WSAGetLastError() != WSAEWOULDBLOCK) {
+ 	
+       printf("io_helper: WSAGetLastError() = %d\n", WSAGetLastError());
+ #endif /* WIN32 */
+ 
+       error = errno;
+       close(s);
+       tmpaddr = tmpaddr->ai_next;
+       continue;
+     } else {
+     
+       return s;
+     }
+   
+     tmpaddr = tmpaddr->ai_next;
+   }
+ 
+   xine_message(stream, XINE_MSG_CONNECTION_REFUSED, strerror(error), NULL);
+   
+   return -1;
+ #endif
+ }
+ 
  
  int xio_select (xine_stream_t *stream, int fd, int state, int timeout_msec) {
  
*** xine-lib-1-rc0a/configure.ac	Sat Aug  2 13:45:26 2003
--- xine-lib-1-rc0a-patched/configure.ac	Wed Sep 24 13:34:45 2003
***************
*** 221,226 ****
--- 221,231 ----
  LIBA52_CFLAGS=""
  LIBFFMPEG_CFLAGS="-DSIMPLE_IDCT -DHAVE_AV_CONFIG_H -DRUNTIME_CPUDETECT -DUSE_FASTMEMCPY -DCONFIG_RISKY -DCONFIG_ENCODERS"
  
+ AC_ARG_ENABLE(ipv6,
+ 	[  --enable-ipv6           enable use of IPv6],
+ 		enable_ipv6=yes,
+ 		enable_ipv6=no)
+ 
  AC_ARG_ENABLE(altivec,
  	[  --disable-altivec       use assembly codes for Motorola 74xx CPUs],
  		enable_altivec=no, 
***************
*** 301,306 ****
--- 306,322 ----
  AC_CHECK_LIB(nsl, gethostbyname, NET_LIBS="-lnsl $NET_LIBS",)
  AC_SUBST(NET_LIBS)
  
+ dnl ---------------------------------------------
+ dnl IPv6
+ dnl ---------------------------------------------
+ echo -n "IPv6 is "
+ if test x$enable_ipv6 = xyes; then
+     CFLAGS="$CFLAGS -DENABLE_IPV6"
+     echo "enabled"
+ else
+     echo "disabled"
+ fi
+ 
  
  dnl ---------------------------------------------
  dnl zlib
*** xine-lib-1-rc0a/src/input/input_http.c	Sun Jul 13 21:29:04 2003
--- xine-lib-1-rc0a-patched.BAK/src/input/input_http.c	Wed Sep 24 08:59:21 2003
***************
*** 205,211 ****
    } else
      if (host != NULL)
        *host = start;
!   
    if (slash != 0)
    {
      *slash = '\0';
--- 205,236 ----
    } else
      if (host != NULL)
        *host = start;
! 
! #ifdef ENABLE_IPV6
!   // Add support for RFC 2732
!   {
!       char *hostbracket, *hostendbracket;
! 
!       hostbracket = strchr(start, '[');
!       if (hostbracket != NULL) {
! 	  
! 	  hostendbracket = strchr(hostbracket, ']');
! 	  
! 	  if (hostendbracket != NULL) {
! 	      
! 	      *hostendbracket = '\0';
! 	      *host = (hostbracket + 1);
! 	      
! 	      // Might have a trailing port
! 	      
! 	      if (*(hostendbracket+1) == ':') {
! 		  portcolon = (hostendbracket + 1);
! 	      }
! 	  }
!       }
!   }
! #endif
! 
    if (slash != 0)
    {
      *slash = '\0';

