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

net_Listen: pass socket type parameter

We cannot use any random type semantic that we do not know of.
This also works around bugs in deficient getaddrinfo() implementations.
parent 5d61b6b2
......@@ -92,9 +92,10 @@ int net_Socket (vlc_object_t *obj, int family, int socktype, int proto);
VLC_EXPORT( int, net_Connect, (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol) );
#define net_Connect(a, b, c, d, e) net_Connect(VLC_OBJECT(a), b, c, d, e)
VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int protocol) );
VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol) );
#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, IPPROTO_TCP)
#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, \
SOCK_STREAM, IPPROTO_TCP)
static inline int net_ConnectTCP (vlc_object_t *obj, const char *host, int port)
{
......
......@@ -1023,8 +1023,12 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
#endif
if( p_sys->psz_destination != NULL )
{
int type = SOCK_STREAM;
switch( p_sys->proto )
{
#ifdef SOCK_DCCP
case IPPROTO_DCCP:
{
const char *code;
......@@ -1036,11 +1040,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
default: code = "RTPORTPV"; break;
}
var_SetString (p_stream, "dccp-service", code);
type = SOCK_DCCP;
} /* fall through */
#endif
case IPPROTO_TCP:
id->listen.fd = net_Listen( VLC_OBJECT(p_stream),
p_sys->psz_destination, i_port,
p_sys->proto );
type, p_sys->proto );
if( id->listen.fd == NULL )
{
msg_Err( p_stream, "passive COMEDIA RTP socket failed" );
......@@ -1072,6 +1078,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
rtp_add_sink( id, fd, p_sys->rtcp_mux, NULL );
}
}
}
if( p_fmt == NULL )
{
......
......@@ -127,11 +127,12 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
int *net_Listen (vlc_object_t *p_this, const char *psz_host,
int i_port, int protocol)
int i_port, int type, int protocol)
{
struct addrinfo hints, *res;
memset (&hints, 0, sizeof( hints ));
hints.ai_socktype = type;
hints.ai_protocol = protocol;
hints.ai_flags = AI_PASSIVE;
......
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