Commit 092858e0 authored by Henri Fallon's avatar Henri Fallon

Repaired broadcast support : binding INADDR_ANY doesn't seem to work.

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]
parent c0138ec5
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* modules. * modules.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Henri Fallon <henri@videolan.org> * Henri Fallon <henri@videolan.org>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
/***************************************************************************** /*****************************************************************************
* Prototypes * 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_BuildRemoteAddr( struct sockaddr_in *, char * );
int network_ChannelJoin( int i_channel_id ); int network_ChannelJoin( int i_channel_id );
int network_ChannelCreate( void ); int network_ChannelCreate( void );
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -537,12 +537,14 @@ void input_FileClose( input_thread_t * p_input ) ...@@ -537,12 +537,14 @@ void input_FileClose( input_thread_t * p_input )
*****************************************************************************/ *****************************************************************************/
void input_NetworkOpen( input_thread_t * p_input ) void input_NetworkOpen( input_thread_t * p_input )
{ {
char *psz_server = NULL; char *psz_server = NULL;
int i_port = 0; int i_port = 0;
int i_opt; int i_opt;
struct sockaddr_in sock; 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 */ /* Get the remote server */
if( p_input->p_source != NULL ) if( p_input->p_source != NULL )
...@@ -636,13 +638,9 @@ void input_NetworkOpen( input_thread_t * p_input ) ...@@ -636,13 +638,9 @@ void input_NetworkOpen( input_thread_t * p_input )
return; 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 */ /* 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 ); close( p_input->i_handle );
p_input->b_error = 1; p_input->b_error = 1;
...@@ -671,7 +669,8 @@ void input_NetworkOpen( input_thread_t * p_input ) ...@@ -671,7 +669,8 @@ void input_NetworkOpen( input_thread_t * p_input )
if( connect( p_input->i_handle, (struct sockaddr *) &sock, if( connect( p_input->i_handle, (struct sockaddr *) &sock,
sizeof( sock ) ) == (-1) ) 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 ); close( p_input->i_handle );
p_input->b_error = 1; p_input->b_error = 1;
return; return;
...@@ -691,6 +690,5 @@ void input_NetworkOpen( input_thread_t * p_input ) ...@@ -691,6 +690,5 @@ void input_NetworkOpen( input_thread_t * p_input )
void input_NetworkClose( input_thread_t * p_input ) void input_NetworkClose( input_thread_t * p_input )
{ {
close( p_input->i_handle ); close( p_input->i_handle );
/* FIXME: deal with channels */
} }
#endif #endif
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* and spawn threads. * and spawn threads.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -169,7 +169,7 @@ static const struct option longopts[] = ...@@ -169,7 +169,7 @@ static const struct option longopts[] =
{ "channels", 0, 0, OPT_CHANNELS }, { "channels", 0, 0, OPT_CHANNELS },
{ "server", 1, 0, OPT_SERVER }, { "server", 1, 0, OPT_SERVER },
{ "port", 1, 0, OPT_PORT }, { "port", 1, 0, OPT_PORT },
{ "broadcast", 0, 0, OPT_BROADCAST }, { "broadcast", 1, 0, OPT_BROADCAST },
/* Synchro options */ /* Synchro options */
{ "synchro", 1, 0, OPT_SYNCHRO }, { "synchro", 1, 0, OPT_SYNCHRO },
...@@ -685,7 +685,7 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] ) ...@@ -685,7 +685,7 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
main_PutPszVariable( INPUT_PORT_VAR, optarg ); main_PutPszVariable( INPUT_PORT_VAR, optarg );
break; break;
case OPT_BROADCAST: /* --broadcast */ case OPT_BROADCAST: /* --broadcast */
main_PutIntVariable( INPUT_BROADCAST_VAR, 1 ); main_PutPszVariable( INPUT_BROADCAST_VAR, optarg );
break; break;
/* Synchro options */ /* Synchro options */
...@@ -834,7 +834,7 @@ static void Usage( int i_fashion ) ...@@ -834,7 +834,7 @@ static void Usage( int i_fashion )
"\n " INPUT_SERVER_VAR "=<hostname> \tvideo server" "\n " INPUT_SERVER_VAR "=<hostname> \tvideo server"
"\n " INPUT_PORT_VAR "=<port> \tvideo server port" "\n " INPUT_PORT_VAR "=<port> \tvideo server port"
"\n " INPUT_IFACE_VAR "=<interface> \tnetwork interface" "\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_SERVER_VAR "=<hostname> \tchannel server"
"\n " INPUT_CHANNEL_PORT_VAR "=<port> \tchannel server port" ); "\n " INPUT_CHANNEL_PORT_VAR "=<port> \tchannel server port" );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* netutils.c: various network functions * netutils.c: various network functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr> * Benoit Steiner <benny@via.ecp.fr>
...@@ -84,7 +84,7 @@ typedef struct input_channel_s ...@@ -84,7 +84,7 @@ typedef struct input_channel_s
* network_BuildLocalAddr : fill a sockaddr_in structure for local binding * network_BuildLocalAddr : fill a sockaddr_in structure for local binding
*****************************************************************************/ *****************************************************************************/
int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port, 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]; char psz_hostname[INPUT_MAX_SOURCE_LENGTH];
struct hostent * p_hostent; struct hostent * p_hostent;
...@@ -93,7 +93,7 @@ int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port, ...@@ -93,7 +93,7 @@ int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port,
memset( p_socket, 0, sizeof( struct sockaddr_in ) ); memset( p_socket, 0, sizeof( struct sockaddr_in ) );
p_socket->sin_family = AF_INET; /* family */ p_socket->sin_family = AF_INET; /* family */
p_socket->sin_port = htons( i_port ); p_socket->sin_port = htons( i_port );
if( !b_broadcast ) if( psz_broadcast == NULL )
{ {
/* Try to get our own IP */ /* Try to get our own IP */
if( gethostname( psz_hostname, sizeof(psz_hostname) ) ) if( gethostname( psz_hostname, sizeof(psz_hostname) ) )
...@@ -105,10 +105,11 @@ int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port, ...@@ -105,10 +105,11 @@ int network_BuildLocalAddr( struct sockaddr_in * p_socket, int i_port,
} }
else else
{ {
/* Instead of trying to find the broadcast address using non-portable /* I didn't manage to make INADDR_ANYT work, even with setsockopt
* ioctl, let's bind INADDR_ANY */ * so, as it's kludgy to try and determine the broadcast addr
strncpy(psz_hostname,"0.0.0.0",sizeof(psz_hostname)); * 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 /* Try to convert address directly from in_addr - this will work if
...@@ -242,7 +243,13 @@ int network_ChannelJoin( int i_channel_id ) ...@@ -242,7 +243,13 @@ int network_ChannelJoin( int i_channel_id )
char i_answer; char i_answer;
fd_set s_rfds; fd_set s_rfds;
unsigned int i_rc; unsigned int i_rc;
if( ! p_main->b_channels )
{
intf_ErrMsg( "Channels disabled. To enable them, use the --channels"
" option" );
return( -1 );
}
/* debug */ /* debug */
intf_DbgMsg( "ChannelJoin : %d", i_channel_id ); intf_DbgMsg( "ChannelJoin : %d", i_channel_id );
/* If last change is too recent, wait a while */ /* If last change is too recent, wait a while */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment