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 @@
* 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 );
......@@ -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>
*
......@@ -539,10 +539,12 @@ void input_NetworkOpen( input_thread_t * p_input )
{
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
......@@ -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" );
......
......@@ -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) ) )
......@@ -106,9 +106,10 @@ 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
......@@ -243,6 +244,12 @@ int network_ChannelJoin( int i_channel_id )
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 */
......
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