Commit 2cce4b1d authored by Gildas Bazin's avatar Gildas Bazin

* modules/misc/network/ipv6.c: gave a quick try to implementing ttl for ipv6.
parent cae87218
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ipv6.c: IPv6 network abstraction layer * ipv6.c: IPv6 network abstraction layer
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: ipv6.c,v 1.10 2003/06/06 11:09:24 gbazin Exp $ * $Id: ipv6.c,v 1.11 2003/06/12 23:03:09 gbazin Exp $
* *
* Authors: Alexis Guillard <alexis.guillard@bt.com> * Authors: Alexis Guillard <alexis.guillard@bt.com>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -65,6 +65,12 @@ static const struct in6_addr in6addr_any = {{IN6ADDR_ANY_INIT}}; ...@@ -65,6 +65,12 @@ static const struct in6_addr in6addr_any = {{IN6ADDR_ANY_INIT}};
#ifndef IPV6_JOIN_GROUP #ifndef IPV6_JOIN_GROUP
# define IPV6_JOIN_GROUP 20 # define IPV6_JOIN_GROUP 20
#endif #endif
#ifndef IPV6_MULTICAST_HOPS
# define IPV6_MULTICAST_HOPS 18
#endif
#ifndef IPV6_UNICAST_HOPS
# define IPV6_UNICAST_HOPS 16
#endif
# define close closesocket # define close closesocket
#endif #endif
...@@ -340,6 +346,9 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket ) ...@@ -340,6 +346,9 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
if( *psz_server_addr ) if( *psz_server_addr )
{ {
int ttl = config_GetInt( p_this, "ttl" );
if( ttl < 1 ) ttl = 1;
/* Build socket for remote connection */ /* Build socket for remote connection */
if ( BuildAddr( p_this, &sock, psz_server_addr, i_server_port ) == -1 ) if ( BuildAddr( p_this, &sock, psz_server_addr, i_server_port ) == -1 )
{ {
...@@ -356,6 +365,39 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket ) ...@@ -356,6 +365,39 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
close( i_handle ); close( i_handle );
return( -1 ); return( -1 );
} }
/* Set the time-to-live */
if( ttl > 1 )
{
#if defined(WIN32) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
if( IN6_IS_ADDR_MULTICAST(&sock.sin6_addr) )
{
if( setsockopt( i_handle, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(void *)&ttl, sizeof( ttl ) ) < 0 )
{
#ifdef HAVE_ERRNO_H
msg_Warn( p_this, "failed to set multicast ttl (%s)",
strerror(errno) );
#else
msg_Warn( p_this, "failed to set multicast ttl" );
#endif
}
}
else
{
if( setsockopt( i_handle, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
(void *)&ttl, sizeof( ttl ) ) < 0 )
{
#ifdef HAVE_ERRNO_H
msg_Warn( p_this, "failed to set unicast ttl (%s)",
strerror(errno) );
#else
msg_Warn( p_this, "failed to set unicast ttl" );
#endif
}
}
#endif
}
} }
p_socket->i_handle = i_handle; p_socket->i_handle = i_handle;
......
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