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

Obsolete confusing --miface-addr option and rework net_SetMcastOut()

--miface-addr mostly did not work as --miface was supposed to be used
instead.
parent da773a8e
......@@ -102,7 +102,6 @@ static const char *const ppsz_core_options[] = {
"dscp",
"ttl",
"miface",
"miface-addr",
NULL
};
......
......@@ -669,11 +669,6 @@ static const char *const ppsz_clock_descriptions[] =
#define MIFACE_LONGTEXT N_( \
"Default multicast interface. This overrides the routing table.")
#define MIFACE_ADDR_TEXT N_("IPv4 multicast output interface address")
#define MIFACE_ADDR_LONGTEXT N_( \
"IPv4 address for the default multicast interface. This overrides " \
"the routing table.")
#define DSCP_TEXT N_("DiffServ Code Point")
#define DSCP_LONGTEXT N_("Differentiated Services Code Point " \
"for outgoing UDP streams (or IPv4 Type Of Service, " \
......@@ -1982,7 +1977,7 @@ vlc_module_begin ()
ACCESS_OUTPUT_TEXT, ACCESS_OUTPUT_LONGTEXT, true )
add_integer( "ttl", -1, TTL_TEXT, TTL_LONGTEXT, true )
add_string( "miface", NULL, MIFACE_TEXT, MIFACE_LONGTEXT, true )
add_string( "miface-addr", NULL, MIFACE_ADDR_TEXT, MIFACE_ADDR_LONGTEXT, true )
add_obsolete_string( "miface-addr" )
add_integer( "dscp", 0, DSCP_TEXT, DSCP_LONGTEXT, true )
set_subcategory( SUBCAT_SOUT_PACKETIZER )
......
......@@ -244,48 +244,9 @@ static int net_SetMcastHopLimit( vlc_object_t *p_this,
}
static int net_SetMcastOutIface (int fd, int family, int scope)
{
switch (family)
{
#ifdef IPV6_MULTICAST_IF
case AF_INET6:
return setsockopt (fd, SOL_IPV6, IPV6_MULTICAST_IF,
&scope, sizeof (scope));
#endif
#ifdef __linux__
case AF_INET:
{
struct ip_mreqn req = { .imr_ifindex = scope };
return setsockopt (fd, SOL_IP, IP_MULTICAST_IF, &req,
sizeof (req));
}
#endif
}
errno = EAFNOSUPPORT;
return -1;
}
static inline int net_SetMcastOutIPv4 (int fd, struct in_addr ipv4)
{
#ifdef IP_MULTICAST_IF
return setsockopt( fd, SOL_IP, IP_MULTICAST_IF, &ipv4, sizeof (ipv4));
#else
errno = EAFNOSUPPORT;
return -1;
#endif
}
static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family,
const char *iface, const char *addr)
const char *iface)
{
if (iface != NULL)
{
int scope = if_nametoindex (iface);
if (scope == 0)
{
......@@ -293,31 +254,28 @@ static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family,
return -1;
}
if (net_SetMcastOutIface (fd, family, scope) == 0)
switch (family)
{
#ifdef IPV6_MULTICAST_IF
case AF_INET6:
if (setsockopt (fd, SOL_IPV6, IPV6_MULTICAST_IF,
&scope, sizeof (scope) == 0))
return 0;
#endif
msg_Err (p_this, "%s: %m", iface);
}
if (addr != NULL)
{
if (family == AF_INET)
{
struct in_addr ipv4;
if (inet_pton (AF_INET, addr, &ipv4) <= 0)
#ifdef __linux__
case AF_INET:
{
msg_Err (p_this, "invalid IPv4 address for multicast: %s",
addr);
return -1;
}
if (net_SetMcastOutIPv4 (fd, ipv4) == 0)
struct ip_mreqn req = { .imr_ifindex = scope };
if (setsockopt (fd, SOL_IP, IP_MULTICAST_IF,
&req, sizeof (req)) == 0)
return 0;
msg_Err (p_this, "%s: %m", addr);
}
#endif
default:
errno = EAFNOSUPPORT;
}
msg_Err (p_this, "cannot force multicast interface %s: %m", iface);
return -1;
}
......@@ -586,14 +544,7 @@ int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
str = var_InheritString (p_this, "miface");
if (str != NULL)
{
net_SetMcastOut (p_this, fd, ptr->ai_family, str, NULL);
free (str);
}
str = var_InheritString (p_this, "miface-addr");
if (str != NULL)
{
net_SetMcastOut (p_this, fd, ptr->ai_family, NULL, str);
net_SetMcastOut (p_this, fd, ptr->ai_family, str);
free (str);
}
......
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