]> git.sesse.net Git - vlc/commitdiff
- replaced inet_pton() with WSAStringToAddress() for WIN32
authorDamien Fouilleul <damienf@videolan.org>
Thu, 28 Jul 2005 13:21:46 +0000 (13:21 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Thu, 28 Jul 2005 13:21:46 +0000 (13:21 +0000)
  needs review, not tested but it compiles

src/stream_output/sap.c

index 638648b8e402694ee4d752d424302cda93003dbb..e4b12dcfcc55f27958d33af985c9a8815a359a8b 100644 (file)
@@ -457,8 +457,29 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     psz_head[2] = (i_hash & 0xFF00) >> 8; /* Msg id hash */
     psz_head[3] = (i_hash & 0xFF);        /* Msg id hash 2 */
 
+#if defined(WIN32)
+    if( b_ipv6 )
+    {
+        struct sockaddr_in6 saddr;
+        int len = sizeof(saddr);
+        if( ! WSAStringToAddress(p_sap_session->p_address->psz_machine,
+                    AF_INET6, NULL, (LPSOCKADDR)&saddr, &len) )
+            return VLC_ENOMEM;
+        memcpy(psz_head+4, &saddr.sin6_addr, sizeof(struct in6_addr));
+    }
+    else
+    {
+        struct sockaddr_in saddr;
+        int len = sizeof(saddr);
+        if( ! WSAStringToAddress(p_sap_session->p_address->psz_machine,
+                    AF_INET, NULL, (LPSOCKADDR)&saddr, &len) )
+            return VLC_ENOMEM;
+        memcpy(psz_head+4, &saddr.sin_addr, sizeof(struct in_addr));
+    }
+#else
     inet_pton( b_ipv6 ? AF_INET6 : AF_INET, /* can't fail */
                p_sap_session->p_address->psz_machine, psz_head + 4 );
+#endif
 
     memcpy( psz_head + (b_ipv6 ? 20 : 8), "application/sdp", 15 );