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[] = { ...@@ -102,7 +102,6 @@ static const char *const ppsz_core_options[] = {
"dscp", "dscp",
"ttl", "ttl",
"miface", "miface",
"miface-addr",
NULL NULL
}; };
......
...@@ -669,11 +669,6 @@ static const char *const ppsz_clock_descriptions[] = ...@@ -669,11 +669,6 @@ static const char *const ppsz_clock_descriptions[] =
#define MIFACE_LONGTEXT N_( \ #define MIFACE_LONGTEXT N_( \
"Default multicast interface. This overrides the routing table.") "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_TEXT N_("DiffServ Code Point")
#define DSCP_LONGTEXT N_("Differentiated Services Code Point " \ #define DSCP_LONGTEXT N_("Differentiated Services Code Point " \
"for outgoing UDP streams (or IPv4 Type Of Service, " \ "for outgoing UDP streams (or IPv4 Type Of Service, " \
...@@ -1982,7 +1977,7 @@ vlc_module_begin () ...@@ -1982,7 +1977,7 @@ vlc_module_begin ()
ACCESS_OUTPUT_TEXT, ACCESS_OUTPUT_LONGTEXT, true ) ACCESS_OUTPUT_TEXT, ACCESS_OUTPUT_LONGTEXT, true )
add_integer( "ttl", -1, TTL_TEXT, TTL_LONGTEXT, true ) add_integer( "ttl", -1, TTL_TEXT, TTL_LONGTEXT, true )
add_string( "miface", NULL, MIFACE_TEXT, MIFACE_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 ) add_integer( "dscp", 0, DSCP_TEXT, DSCP_LONGTEXT, true )
set_subcategory( SUBCAT_SOUT_PACKETIZER ) set_subcategory( SUBCAT_SOUT_PACKETIZER )
......
...@@ -244,80 +244,38 @@ static int net_SetMcastHopLimit( vlc_object_t *p_this, ...@@ -244,80 +244,38 @@ static int net_SetMcastHopLimit( vlc_object_t *p_this,
} }
static int net_SetMcastOutIface (int fd, int family, int scope) static int net_SetMcastOut (vlc_object_t *p_this, int fd, int family,
const char *iface)
{ {
int scope = if_nametoindex (iface);
if (scope == 0)
{
msg_Err (p_this, "invalid multicast interface: %s", iface);
return -1;
}
switch (family) switch (family)
{ {
#ifdef IPV6_MULTICAST_IF #ifdef IPV6_MULTICAST_IF
case AF_INET6: case AF_INET6:
return setsockopt (fd, SOL_IPV6, IPV6_MULTICAST_IF, if (setsockopt (fd, SOL_IPV6, IPV6_MULTICAST_IF,
&scope, sizeof (scope)); &scope, sizeof (scope) == 0))
return 0;
#endif #endif
#ifdef __linux__ #ifdef __linux__
case AF_INET: case AF_INET:
{ {
struct ip_mreqn req = { .imr_ifindex = scope }; struct ip_mreqn req = { .imr_ifindex = scope };
if (setsockopt (fd, SOL_IP, IP_MULTICAST_IF,
return setsockopt (fd, SOL_IP, IP_MULTICAST_IF, &req, &req, sizeof (req)) == 0)
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)
{
if (iface != NULL)
{
int scope = if_nametoindex (iface);
if (scope == 0)
{
msg_Err (p_this, "invalid multicast interface: %s", iface);
return -1;
}
if (net_SetMcastOutIface (fd, family, scope) == 0)
return 0;
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)
{
msg_Err (p_this, "invalid IPv4 address for multicast: %s",
addr);
return -1;
}
if (net_SetMcastOutIPv4 (fd, ipv4) == 0)
return 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; return -1;
} }
...@@ -586,14 +544,7 @@ int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -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"); str = var_InheritString (p_this, "miface");
if (str != NULL) if (str != NULL)
{ {
net_SetMcastOut (p_this, fd, ptr->ai_family, str, NULL); net_SetMcastOut (p_this, fd, ptr->ai_family, str);
free (str);
}
str = var_InheritString (p_this, "miface-addr");
if (str != NULL)
{
net_SetMcastOut (p_this, fd, ptr->ai_family, NULL, str);
free (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