]> git.sesse.net Git - vlc/commitdiff
Repaired broadcast support : binding INADDR_ANY doesn't seem to work.
authorHenri Fallon <henri@videolan.org>
Fri, 27 Apr 2001 18:07:57 +0000 (18:07 +0000)
committerHenri Fallon <henri@videolan.org>
Fri, 27 Apr 2001 18:07:57 +0000 (18:07 +0000)
You now have to specify the broadcast address as an argument.
Btw, thanks to sam, you can now use ts://server:port style, which gives
for broadcast :

vlc --broadcast broadcast_addr ts://server[:port]

include/netutils.h
src/input/input.c
src/interface/main.c
src/misc/netutils.c

index fe5cfc6d8e0a7fbc1e5dffc1b88fcd6e33bcd990..96b93b203d0c0be7f6baf074bc8cd21b2243f0da 100644 (file)
@@ -4,7 +4,7 @@
  * modules.
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: netutils.h,v 1.10 2001/04/11 02:01:24 henri Exp $
+ * $Id: netutils.h,v 1.11 2001/04/27 18:07:56 henri Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Henri Fallon <henri@videolan.org>
@@ -30,7 +30,7 @@
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
-int network_BuildLocalAddr ( struct sockaddr_in *, int, boolean_t ); 
+int network_BuildLocalAddr ( struct sockaddr_in *, int, char * ); 
 int network_BuildRemoteAddr( struct sockaddr_in *, char * );
 int network_ChannelJoin( int i_channel_id );
 int network_ChannelCreate( void );
index 5c546518813d0903510e37abc0bc83638da7e559..106f6ea778a363fdb62186fb0c3d74fb5bebfbd4 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.100 2001/04/27 16:08:26 sam Exp $
+ * $Id: input.c,v 1.101 2001/04/27 18:07:56 henri Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -537,12 +537,14 @@ void input_FileClose( input_thread_t * p_input )
  *****************************************************************************/
 void input_NetworkOpen( input_thread_t * p_input )
 {
-    char *psz_server = NULL;
-    int   i_port = 0;
-
+    char                *psz_server = NULL;
+    int                 i_port = 0;
     int                 i_opt;
     struct sockaddr_in  sock;
-    boolean_t           b_broadcast;
+    char *              psz_broadcast;
+    
+    /* Are we broadcasting ? */
+    psz_broadcast = main_GetPszVariable( INPUT_BROADCAST_VAR, NULL );
     
     /* Get the remote server */
     if( p_input->p_source != NULL )
@@ -636,13 +638,9 @@ void input_NetworkOpen( input_thread_t * p_input )
         return;
     }
 
-    /* Get details about what we are supposed to do */
-    b_broadcast = (boolean_t)main_GetIntVariable( INPUT_BROADCAST_VAR, 0 );
-
-    /* TODO : here deal with channel stuff */
-    
     /* Build the local socket */
-    if ( network_BuildLocalAddr( &sock, i_port, b_broadcast ) == -1 )
+    if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast ) 
+         == -1 )
     {
         close( p_input->i_handle );
         p_input->b_error = 1;
@@ -671,7 +669,8 @@ void input_NetworkOpen( input_thread_t * p_input )
     if( connect( p_input->i_handle, (struct sockaddr *) &sock,
                  sizeof( sock ) ) == (-1) )
     {
-        intf_ErrMsg("input error: can't connect socket" );
+        intf_ErrMsg( "NetworkOpen: can't connect socket : %s", 
+                     strerror(errno) );
         close( p_input->i_handle );
         p_input->b_error = 1;
         return;
@@ -691,6 +690,5 @@ void input_NetworkOpen( input_thread_t * p_input )
 void input_NetworkClose( input_thread_t * p_input )
 {
     close( p_input->i_handle );
-    /* FIXME: deal with channels */
 }
 #endif
index 5bf124e477d9f474a11b0bc05c2858780e923814..5a7e23aec5cccdf1fd68edbefb7ead8065fad898 100644 (file)
@@ -4,7 +4,7 @@
  * and spawn threads.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: main.c,v 1.87 2001/04/20 05:40:03 stef Exp $
+ * $Id: main.c,v 1.88 2001/04/27 18:07:56 henri Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -169,7 +169,7 @@ static const struct option longopts[] =
     {   "channels",         0,          0,      OPT_CHANNELS },
     {   "server",           1,          0,      OPT_SERVER },
     {   "port",             1,          0,      OPT_PORT },
-    {   "broadcast",        0,          0,      OPT_BROADCAST },
+    {   "broadcast",        1,          0,      OPT_BROADCAST },
 
     /* Synchro options */
     {   "synchro",          1,          0,      OPT_SYNCHRO },
@@ -685,7 +685,7 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
             main_PutPszVariable( INPUT_PORT_VAR, optarg );
             break;
         case OPT_BROADCAST:                                   /* --broadcast */
-            main_PutIntVariable( INPUT_BROADCAST_VAR, 1 );
+            main_PutPszVariable( INPUT_BROADCAST_VAR, optarg );
             break;
 
         /* Synchro options */
@@ -834,7 +834,7 @@ static void Usage( int i_fashion )
         "\n  " INPUT_SERVER_VAR "=<hostname>          \tvideo server"
         "\n  " INPUT_PORT_VAR "=<port>            \tvideo server port"
         "\n  " INPUT_IFACE_VAR "=<interface>          \tnetwork interface"
-        "\n  " INPUT_BROADCAST_VAR "={1|0}            \tbroadcast mode"
+        "\n  " INPUT_BROADCAST_VAR "=<addr>            \tbroadcast mode"
         "\n  " INPUT_CHANNEL_SERVER_VAR "=<hostname>     \tchannel server"
         "\n  " INPUT_CHANNEL_PORT_VAR "=<port>         \tchannel server port" );
 
index 047cd46ff9388ee4bd82e8e5ed02ce1d68f4c08f..70decac2c65d4de38b573c78b1638b3344753a35 100644 (file)
@@ -2,7 +2,7 @@
  * netutils.c: various network functions
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: netutils.c,v 1.26 2001/04/27 16:08:26 sam Exp $
+ * $Id: netutils.c,v 1.27 2001/04/27 18:07:57 henri Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Benoit Steiner <benny@via.ecp.fr>
@@ -84,7 +84,7 @@ typedef struct input_channel_s
  * network_BuildLocalAddr : fill a sockaddr_in structure for local binding
  *****************************************************************************/
 int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port, 
-                            boolean_t b_broadcast )
+                            char * psz_broadcast )
 {
     char                psz_hostname[INPUT_MAX_SOURCE_LENGTH];
     struct hostent    * p_hostent;
@@ -93,7 +93,7 @@ int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port,
     memset( p_socket, 0, sizeof( struct sockaddr_in ) );
     p_socket->sin_family = AF_INET;                                 /* family */
     p_socket->sin_port = htons( i_port );
-    if( !b_broadcast )
+    if( psz_broadcast == NULL )
     {
         /* Try to get our own IP */
         if( gethostname( psz_hostname, sizeof(psz_hostname) ) )
@@ -105,10 +105,11 @@ int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port,
 
     }
     else
-    {
-        /* Instead of trying to find the broadcast address using non-portable
-         * ioctl, let's bind INADDR_ANY */
-        strncpy(psz_hostname,"0.0.0.0",sizeof(psz_hostname));
+    {   
+        /* I didn't manage to make INADDR_ANYT work, even with setsockopt 
+         * so, as it's kludgy to try and determine the broadcast addr
+         * it is passed as an argument in the command line */
+        strncpy( psz_hostname, psz_broadcast, INPUT_MAX_SOURCE_LENGTH );
     }
 
     /* Try to convert address directly from in_addr - this will work if
@@ -242,7 +243,13 @@ int network_ChannelJoin( int i_channel_id )
     char                i_answer;
     fd_set              s_rfds;
     unsigned int       i_rc;
-    
+    if( ! p_main->b_channels )
+    {
+        intf_ErrMsg( "Channels disabled. To enable them, use the --channels"
+                     " option" );
+        return( -1 );
+    }
     /* debug */ 
     intf_DbgMsg( "ChannelJoin : %d", i_channel_id );
     /* If last change is too recent, wait a while */