]> git.sesse.net Git - vlc/commitdiff
net_Listen: pass socket type parameter
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 5 May 2010 16:15:48 +0000 (19:15 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 5 May 2010 16:29:57 +0000 (19:29 +0300)
We cannot use any random type semantic that we do not know of.
This also works around bugs in deficient getaddrinfo() implementations.

include/vlc_network.h
modules/stream_out/rtp.c
src/network/io.c

index 77b38290b24c05a9a0cbc8b0be19eb7ac65c8321..0a51a12ee3107d0ca4c83f87685519712938de4c 100644 (file)
@@ -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)
 {
index ab3907b167bb17b8b64313865f561add894e1917..2199469f95ade1376d59264dfcfc94eb8a0b9a40 100644 (file)
@@ -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 )
     {
index c4238d58bf7d3b80edef66ef31a0bcdf5bf0fa65..2defe3188b5e3193328b0bc36019c3d21ab88ebb 100644 (file)
@@ -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;