]> git.sesse.net Git - vlc/blobdiff - src/stream_output/acl.c
Use RTP for wizard, since it's capable of packet reordering.
[vlc] / src / stream_output / acl.c
index e4b40703f883772d73223507472fe7a0b4fc0f96..9a957d1a7a50df82390830c5e1859d9609763c5c 100644 (file)
 
 #include "vlc_acl.h"
 
-#ifdef HAVE_ERRNO_H
 #include <errno.h>
-#endif
-
-#if defined( WIN32 ) || defined( UNDER_CE )
-#   include <winsock2.h>
-#   include <ws2tcpip.h>
-#else
-#   include <sys/socket.h>
-#   include <netinet/in.h>
-#   include <netdb.h>
-#endif
 
 #include "network.h"
 
 /* FIXME: rwlock on acl, but libvlc doesn't implement rwlock */
-/* FIXME: move to src/stream_output/whatever */
 typedef struct vlc_acl_entry_t
 {
     uint8_t    host[17];
@@ -67,7 +55,7 @@ struct vlc_acl_t
 static int ACL_Resolve( vlc_object_t *p_this, uint8_t *p_bytes,
                         const char *psz_ip )
 {
-    struct addrinfo hints = { }, *res;
+    struct addrinfo hints = { }, *res;
     int i_family;
 
     hints.ai_socktype = SOCK_STREAM; /* doesn't matter */
@@ -165,6 +153,9 @@ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len,
     if( p_ent == NULL )
         return -1;
 
+    p_acl->p_entries = p_ent;
+    p_ent += i_size;
+
     i_family = ACL_Resolve( p_acl->p_owner, p_ent->host, psz_ip );
     if( i_family < 0 )
     {
@@ -181,9 +172,6 @@ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len,
         if( i_family == AF_INET )
             i_len += 96;
 
-        p_acl->p_entries = p_ent;
-        p_ent += i_size;
-
         if( i_len > 128 )
             i_len = 128;
         else
@@ -231,20 +219,28 @@ vlc_acl_t *__ACL_Duplicate( vlc_object_t *p_this, const vlc_acl_t *p_acl )
     if( p_dupacl == NULL )
         return NULL;
 
-    p_dupacl->p_entries = (vlc_acl_entry_t *)
-        malloc( p_acl->i_size * sizeof( vlc_acl_entry_t ) );
-    if( p_dupacl->p_entries == NULL )
+    if( p_acl->i_size )
     {
-        free( p_dupacl );
-        return NULL;
-    }   
+        p_dupacl->p_entries = (vlc_acl_entry_t *)
+            malloc( p_acl->i_size * sizeof( vlc_acl_entry_t ) );
+
+        if( p_dupacl->p_entries == NULL )
+        {
+            free( p_dupacl );
+            return NULL;
+        }
+
+        memcpy( p_dupacl->p_entries, p_acl->p_entries,
+                p_acl->i_size * sizeof( vlc_acl_entry_t ) );
+    }
+    else
+        p_dupacl->p_entries = NULL;
 
     vlc_object_yield( p_this );
     p_dupacl->p_owner = p_this;
     p_dupacl->i_size = p_acl->i_size;
-    memcpy( p_dupacl->p_entries, p_acl->p_entries,
-            p_dupacl->i_size * sizeof( vlc_acl_entry_t ) );
-    
+    p_dupacl->b_allow_default = p_acl->b_allow_default;
+
     return p_dupacl;
 }