Commit 3ce5cf59 authored by Gildas Bazin's avatar Gildas Bazin

* First try for IPv6 support on Win32. This hasn't been tested so it
  might not work! To compile this stuff you need a mingw compiler with
  w32api-1.3.

The win32 code uses the getaddrinfo function because inet_pton is
supposed to be deprecated and not supported by Microsoft. gethostbyname2
isn't supported as well. Maybe we could try to unify the ipv6 plugin and
have all the ports use getaddrinfo ? (I didn't dare to do it because I
don't want to break anything before a release ;-)
parent 778c00c7
......@@ -107,6 +107,7 @@ imdct_LDFLAGS = @imdct_LDFLAGS@
imdct3dn_LDFLAGS = @imdct3dn_LDFLAGS@
imdctsse_LDFLAGS = @imdctsse_LDFLAGS@
ipv4_LDFLAGS = @ipv4_LDFLAGS@
ipv6_LDFLAGS = @ipv6_LDFLAGS@
kde_LDFLAGS = @kde_LDFLAGS@
lirc_LDFLAGS = @lirc_LDFLAGS@
macosx_LDFLAGS = @macosx_LDFLAGS@
......
This diff is collapsed.
......@@ -79,6 +79,7 @@ case x"${target_os}" in
vlc_LDFLAGS="${vlc_LDFLAGS} -mwindows -Xlinker --force-exe-suffix"
vlc_LDFLAGS="${vlc_LDFLAGS} -lws2_32 -lnetapi32"
ipv4_LDFLAGS="${ipv4_LDFLAGS} -lws2_32"
ipv6_LDFLAGS="${ipv6_LDFLAGS} -lws2_32"
rc_LDFLAGS="${rc_LDFLAGS} -lws2_32"
;;
x*nto*)
......@@ -781,10 +782,16 @@ AC_ARG_ENABLE(satellite,
dnl
dnl ipv6 plugin - not for QNX yet
dnl
if test x$SYS != xnto
if test x$SYS != xnto && test "x$SYS" != "xmingw32"
then
AC_CHECK_FUNC(inet_pton,[PLUGINS="${PLUGINS} ipv6"])
fi
if test "x$SYS" = "xmingw32"
then
AC_MSG_CHECKING(for getaddrinfo in ws2tcpip.h)
AC_EGREP_HEADER(addrinfo,ws2tcpip.h,[AC_MSG_RESULT(yes)
PLUGINS="${PLUGINS} ipv6"],[AC_MSG_RESULT(no)])
fi
dnl
dnl AVI demux plugin
......@@ -1700,6 +1707,7 @@ AC_SUBST(imdct_LDFLAGS)
AC_SUBST(imdct3dn_LDFLAGS)
AC_SUBST(imdctsse_LDFLAGS)
AC_SUBST(ipv4_LDFLAGS)
AC_SUBST(ipv6_LDFLAGS)
AC_SUBST(kde_LDFLAGS)
AC_SUBST(lirc_LDFLAGS)
AC_SUBST(macosx_LDFLAGS)
......
......@@ -2,7 +2,7 @@
* ipv6.c: IPv6 network abstraction layer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: ipv6.c,v 1.6 2002/04/23 14:16:20 sam Exp $
* $Id: ipv6.c,v 1.7 2002/05/20 19:49:18 gbazin Exp $
*
* Authors: Alexis Guillard <alexis.guillard@bt.com>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -27,11 +27,11 @@
*****************************************************************************/
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <videolan/vlc.h>
#ifdef HAVE_UNISTD_H
......@@ -58,6 +58,10 @@
* call to get that value from the interface driver. */
#define DEFAULT_MTU 1500
#if defined(WIN32)
static const struct in6_addr in6addr_any = {{IN6ADDR_ANY_INIT}};
#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -100,9 +104,37 @@ static void getfunctions( function_list_t * p_function_list )
static int BuildAddr( struct sockaddr_in6 * p_socket,
char * psz_address, int i_port )
{
#if defined(WIN32)
/* Try to get getaddrinfo() and freeaddrinfo() from wship6.dll */
typedef int (CALLBACK * GETADDRINFO) ( const char *nodename,
const char *servname,
const struct addrinfo *hints,
struct addrinfo **res );
typedef void (CALLBACK * FREEADDRINFO) ( struct addrinfo FAR *ai );
struct addrinfo hints, *res;
GETADDRINFO _getaddrinfo = NULL;
FREEADDRINFO _freeaddrinfo = NULL;
HINSTANCE wship6_dll = LoadLibrary("wship6.dll");
if( wship6_dll )
{
_getaddrinfo = (GETADDRINFO) GetProcAddress( wship6_dll,
"getaddrinfo" );
_freeaddrinfo = (FREEADDRINFO) GetProcAddress( wship6_dll,
"freeaddrinfo" );
}
if( !_getaddrinfo || !_freeaddrinfo )
{
intf_ErrMsg( "ipv6 error: no IPv6 stack installed" );
FreeLibrary( wship6_dll );
return( -1 );
}
#endif
/* Reset struct */
memset( p_socket, 0, sizeof( struct sockaddr_in6 ) );
p_socket->sin6_family = AF_INET6; /* family */
p_socket->sin6_family = AF_INET6; /* family */
p_socket->sin6_port = htons( i_port );
if( !*psz_address )
{
......@@ -113,7 +145,26 @@ static int BuildAddr( struct sockaddr_in6 * p_socket,
{
psz_address++;
psz_address[strlen(psz_address) - 1] = '\0' ;
#if !defined( WIN32 )
inet_pton(AF_INET6, psz_address, &p_socket->sin6_addr.s6_addr);
#else
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET6;
hints.ai_flags = AI_NUMERICHOST;
if( _getaddrinfo( psz_address, NULL, &hints, &res ) )
{
FreeLibrary( wship6_dll );
return( -1 );
}
memcpy( &p_socket->sin6_addr,
&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr,
sizeof(struct in6_addr) );
_freeaddrinfo( res );
#endif
}
else
{
......@@ -130,12 +181,28 @@ static int BuildAddr( struct sockaddr_in6 * p_socket,
/* 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 );
#elif defined(WIN32)
if( _getaddrinfo( psz_address, NULL, &hints, &res ) )
{
FreeLibrary( wship6_dll );
return( -1 );
}
memcpy( &p_socket->sin6_addr,
&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr,
sizeof(struct in6_addr) );
_freeaddrinfo( res );
#else
intf_ErrMsg( "ipv6 error: IPv6 address %s is invalid", psz_address );
return( -1 );
#endif
}
#if defined(WIN32)
FreeLibrary( wship6_dll );
#endif
return( 0 );
}
......@@ -337,5 +404,3 @@ static int NetworkOpen( network_socket_t * p_socket )
return OpenTCP( p_socket );
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment