]> git.sesse.net Git - vlc/commitdiff
Fallback for UDP if not using IPv4
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 17 Jul 2004 15:04:42 +0000 (15:04 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 17 Jul 2004 15:04:42 +0000 (15:04 +0000)
modules/access/mms/mmstu.c

index ccaec7006456fd5b3e2352a471e1f893778acc96..ce8a1f510cfed63234990f9d0de3eb36fae43010 100644 (file)
@@ -459,8 +459,8 @@ static int MMSOpen( access_t  *p_access, vlc_url_t *p_url, int  i_proto )
     /* *** Bind port if UDP protocol is selected *** */
     if( b_udp )
     {
-        struct sockaddr_in name;
-        socklen_t i_namelen = sizeof( struct sockaddr_in );
+        struct sockaddr_storage name;
+        socklen_t i_namelen = sizeof( name );
 
         if( getsockname( p_sys->i_handle_tcp,
                          (struct sockaddr*)&name, &i_namelen ) < 0 )
@@ -468,7 +468,13 @@ static int MMSOpen( access_t  *p_access, vlc_url_t *p_url, int  i_proto )
             net_Close( p_sys->i_handle_tcp );
             return VLC_EGENERIC;
         }
-        p_sys->psz_bind_addr = inet_ntoa( name.sin_addr );
+
+        /* FIXME: not thread-safe for IPv4 */
+        /* FIXME: not sure if it works fine for IPv6 */
+        if( name.ss_family == AF_INET )
+            p_sys->psz_bind_addr = inet_ntoa( ((struct sockaddr_in *)&name)->sin_addr );
+        else
+            p_sys->psz_bind_addr = p_url->psz_host;
 
         p_sys->i_handle_udp = net_OpenUDP( p_access, p_sys->psz_bind_addr, 7000, "", 0 );
         if( p_sys->i_handle_udp < 0 )