]> git.sesse.net Git - vlc/commitdiff
udp.c: MakeRandMulticast fix for win32, courmisch to review
authorDamien Fouilleul <damienf@videolan.org>
Mon, 12 Feb 2007 14:54:46 +0000 (14:54 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Mon, 12 Feb 2007 14:54:46 +0000 (14:54 +0000)
modules/access_output/udp.c

index 24718b428aea4bd940ab996623add91d5d3d33a9..423b49a56fc21c1a4d2c73029b0342b252b2ad5a 100644 (file)
@@ -653,7 +653,16 @@ static const char *MakeRandMulticast (int family, char *buf, size_t buflen)
                            "\x00\x00\x00\x00", 12);
             rand |= 0x80000000;
             memcpy (addr.s6_addr + 12, &(uint32_t){ htonl (rand) }, 4);
+#if defined(WIN32) || defined(UNDER_CE)
+            if( 0 == WSAAddressToStringA((LPSOCKADDR)&addr, sizeof(struct in6_addr), NULL, buf, &buflen) )
+            {
+                buf[buflen] = '\0';
+                return buf;
+            }
+            return NULL;
+#else
             return inet_ntop (family, &addr, buf, buflen);
+#endif
         }
 #endif
 
@@ -661,9 +670,22 @@ static const char *MakeRandMulticast (int family, char *buf, size_t buflen)
         {
             struct in_addr addr;
             addr.s_addr = htonl ((rand & 0xffffff) | 0xe8000000);
+#if defined(WIN32) || defined(UNDER_CE)
+            if( 0 == WSAAddressToStringA((LPSOCKADDR)&addr, sizeof(struct in_addr), NULL, buf, &buflen) )
+            {
+                buf[buflen] = '\0';
+                return buf;
+            }
+            return NULL;
+#else
             return inet_ntop (family, &addr, buf, buflen);
+#endif
         }
     }
+#if defined(WIN32) || defined(UNDER_CE)
+    WSASetLastError(WSAEAFNOSUPPORT);
+#else
     errno = EAFNOSUPPORT;
+#endif
     return NULL;
 }