Commit 6a389c94 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* ipv4.c: ttl setsockopt fix. Thanks to Emmanuel Dreyfus for reporting

parent 6c4b8e5a
......@@ -409,15 +409,27 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
if( IN_MULTICAST( ntohl(inet_addr(psz_server_addr) ) ) )
{
/* set the time-to-live */
int ttl = p_socket->i_ttl;
if( ttl < 1 )
int i_ttl = p_socket->i_ttl;
unsigned char ttl;
if( i_ttl < 1 )
{
ttl = config_GetInt( p_this, "ttl" );
i_ttl = config_GetInt( p_this, "i_ttl" );
}
if( ttl < 1 ) ttl = 1;
if( i_ttl < 1 ) i_ttl = 1;
ttl = (unsigned char) i_ttl;
/* There is some confusion in the world whether IP_MULTICAST_TTL
* takes a byte or an int as an argument. BSD seems to indicate byte
* so we are going with that and use int as a fallback to be safe */
if( setsockopt( i_handle, IPPROTO_IP, IP_MULTICAST_TTL,
&ttl, sizeof( ttl ) ) < 0 )
{
#ifdef HAVE_ERRNO_H
msg_Dbg( p_this, "failed to set ttl (%s). Let's try it the integer way.", strerror(errno) );
#endif
if( setsockopt( i_handle, IPPROTO_IP, IP_MULTICAST_TTL,
(void *) &ttl, sizeof( ttl ) ) < 0 )
&i_ttl, sizeof( i_ttl ) ) <0 )
{
#ifdef HAVE_ERRNO_H
msg_Err( p_this, "failed to set ttl (%s)", strerror(errno) );
......@@ -428,6 +440,7 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
return( -1 );
}
}
}
#endif
}
......
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