Commit 074c4a99 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.
(cherry picked from commit bb7ae441)
parent e8283156
...@@ -92,9 +92,10 @@ int net_Socket (vlc_object_t *obj, int family, int socktype, int proto); ...@@ -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) ); 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) #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) 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 ) ...@@ -1023,8 +1023,12 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
#endif #endif
if( p_sys->psz_destination != NULL ) if( p_sys->psz_destination != NULL )
{
int type = SOCK_STREAM;
switch( p_sys->proto ) switch( p_sys->proto )
{ {
#ifdef SOCK_DCCP
case IPPROTO_DCCP: case IPPROTO_DCCP:
{ {
const char *code; const char *code;
...@@ -1036,11 +1040,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1036,11 +1040,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
default: code = "RTPORTPV"; break; default: code = "RTPORTPV"; break;
} }
var_SetString (p_stream, "dccp-service", code); var_SetString (p_stream, "dccp-service", code);
type = SOCK_DCCP;
} /* fall through */ } /* fall through */
#endif
case IPPROTO_TCP: case IPPROTO_TCP:
id->listen.fd = net_Listen( VLC_OBJECT(p_stream), id->listen.fd = net_Listen( VLC_OBJECT(p_stream),
p_sys->psz_destination, i_port, p_sys->psz_destination, i_port,
p_sys->proto ); type, p_sys->proto );
if( id->listen.fd == NULL ) if( id->listen.fd == NULL )
{ {
msg_Err( p_stream, "passive COMEDIA RTP socket failed" ); 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 ) ...@@ -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 ); rtp_add_sink( id, fd, p_sys->rtcp_mux, NULL );
} }
} }
}
if( p_fmt == NULL ) if( p_fmt == NULL )
{ {
......
...@@ -127,11 +127,12 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype, ...@@ -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 *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; struct addrinfo hints, *res;
memset (&hints, 0, sizeof( hints )); memset (&hints, 0, sizeof( hints ));
hints.ai_socktype = type;
hints.ai_protocol = protocol; hints.ai_protocol = protocol;
#ifdef WIN32 #ifdef WIN32
......
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