Commit dc7dd8bf authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

- Use OS default TTL when not overriden

- Clean up
(refs #404)
parent 51c0881c
/***************************************************************************** /*****************************************************************************
* ipv4.c: IPv4 network abstraction layer * ipv4.c: IPv4 network abstraction layer
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2005 the VideoLAN team * Copyright (C) 2001-2006 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -437,7 +437,6 @@ static int OpenUDP( vlc_object_t * p_this ) ...@@ -437,7 +437,6 @@ static int OpenUDP( vlc_object_t * p_this )
{ {
/* set the time-to-live */ /* set the time-to-live */
int i_ttl = p_socket->i_ttl; int i_ttl = p_socket->i_ttl;
unsigned char ttl;
/* set the multicast interface */ /* set the multicast interface */
char * psz_mif_addr = config_GetPsz( p_this, "miface-addr" ); char * psz_mif_addr = config_GetPsz( p_this, "miface-addr" );
...@@ -456,18 +455,12 @@ static int OpenUDP( vlc_object_t * p_this ) ...@@ -456,18 +455,12 @@ static int OpenUDP( vlc_object_t * p_this )
} }
} }
if( i_ttl < 1 ) if( i_ttl <= 0 )
{ i_ttl = config_GetInt( p_this, "ttl" );
if( var_Get( p_this, "ttl", &val ) != VLC_SUCCESS )
if( i_ttl > 0 )
{ {
var_Create( p_this, "ttl", unsigned char ttl = (unsigned char) i_ttl;
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, "ttl", &val );
}
i_ttl = val.i_int;
}
if( i_ttl < 1 ) i_ttl = 1;
ttl = (unsigned char) i_ttl;
/* There is some confusion in the world whether IP_MULTICAST_TTL /* There is some confusion in the world whether IP_MULTICAST_TTL
* takes a byte or an int as an argument. * takes a byte or an int as an argument.
...@@ -488,6 +481,7 @@ static int OpenUDP( vlc_object_t * p_this ) ...@@ -488,6 +481,7 @@ static int OpenUDP( vlc_object_t * p_this )
} }
} }
} }
}
#endif #endif
} }
......
...@@ -255,7 +255,6 @@ static int OpenUDP( vlc_object_t * p_this ) ...@@ -255,7 +255,6 @@ static int OpenUDP( vlc_object_t * p_this )
} }
/* Join the multicast group if the socket is a multicast address */ /* Join the multicast group if the socket is a multicast address */
#if defined( WIN32 ) || defined( HAVE_IF_NAMETOINDEX )
if( IN6_IS_ADDR_MULTICAST(&sock.sin6_addr) ) if( IN6_IS_ADDR_MULTICAST(&sock.sin6_addr) )
{ {
if(*psz_server_addr) if(*psz_server_addr)
...@@ -310,19 +309,12 @@ static int OpenUDP( vlc_object_t * p_this ) ...@@ -310,19 +309,12 @@ static int OpenUDP( vlc_object_t * p_this )
} }
} }
} }
#else
msg_Warn( p_this, "Multicast IPv6 is not supported on your OS" );
#endif
if( *psz_server_addr ) if( *psz_server_addr )
{ {
int ttl = p_socket->i_ttl; int ttl = p_socket->i_ttl;
if( ttl < 1 ) if( ttl <= 0 )
{
ttl = config_GetInt( p_this, "ttl" ); 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 )
...@@ -342,7 +334,7 @@ static int OpenUDP( vlc_object_t * p_this ) ...@@ -342,7 +334,7 @@ static int OpenUDP( vlc_object_t * p_this )
} }
/* Set the time-to-live */ /* Set the time-to-live */
if( ttl > 1 ) if( ttl > 0 )
{ {
#if defined( WIN32 ) || defined( HAVE_IF_NAMETOINDEX ) #if defined( WIN32 ) || defined( HAVE_IF_NAMETOINDEX )
if( IN6_IS_ADDR_MULTICAST(&sock.sin6_addr) ) if( IN6_IS_ADDR_MULTICAST(&sock.sin6_addr) )
......
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