mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-16 16:02:54 +02:00
* ipv4.c: ttl setsockopt fix. Thanks to Emmanuel Dreyfus for reporting
This commit is contained in:
parent
6c4b8e5ab8
commit
6a389c9442
@ -409,23 +409,36 @@ 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 )
|
||||
{
|
||||
ttl = config_GetInt( p_this, "ttl" );
|
||||
}
|
||||
if( ttl < 1 ) ttl = 1;
|
||||
int i_ttl = p_socket->i_ttl;
|
||||
unsigned char ttl;
|
||||
|
||||
if( i_ttl < 1 )
|
||||
{
|
||||
i_ttl = config_GetInt( p_this, "i_ttl" );
|
||||
}
|
||||
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,
|
||||
(void *) &ttl, sizeof( ttl ) ) < 0 )
|
||||
&ttl, sizeof( ttl ) ) < 0 )
|
||||
{
|
||||
#ifdef HAVE_ERRNO_H
|
||||
msg_Err( p_this, "failed to set ttl (%s)", strerror(errno) );
|
||||
#else
|
||||
msg_Err( p_this, "failed to set ttl" );
|
||||
msg_Dbg( p_this, "failed to set ttl (%s). Let's try it the integer way.", strerror(errno) );
|
||||
#endif
|
||||
close( i_handle );
|
||||
return( -1 );
|
||||
if( setsockopt( i_handle, IPPROTO_IP, IP_MULTICAST_TTL,
|
||||
&i_ttl, sizeof( i_ttl ) ) <0 )
|
||||
{
|
||||
#ifdef HAVE_ERRNO_H
|
||||
msg_Err( p_this, "failed to set ttl (%s)", strerror(errno) );
|
||||
#else
|
||||
msg_Err( p_this, "failed to set ttl" );
|
||||
#endif
|
||||
close( i_handle );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user