* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.156 2001/11/15 18:50:49 sam Exp $
+ * $Id: input.c,v 1.157 2001/11/21 16:47:46 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
int i_opt;
int i_opt_size;
struct sockaddr_in sock;
- unsigned int i_mc_group;
/* Get the remote server */
if( p_input->p_source != NULL )
return;
}
- /* Required for IP_ADD_MEMBERSHIP */
- i_mc_group = sock.sin_addr.s_addr;
-
-#if defined( WIN32 )
- sock.sin_addr.s_addr = INADDR_ANY;
-
-#define IN_MULTICAST(a) IN_CLASSD(a)
-#endif
-
/* Bind it */
if( bind( p_input->i_handle, (struct sockaddr *)&sock,
sizeof( sock ) ) < 0 )
/* Join the multicast group if the socket is a multicast address */
+#if defined( WIN32 )
+# define IN_MULTICAST(a) IN_CLASSD(a)
+#endif
+
+ /* TODO : make this compile under Win32 */
#ifndef WIN32
- if( IN_MULTICAST( ntohl(i_mc_group) ) )
+ if( IN_MULTICAST( ntohl(sock.sin_addr.s_addr) ) )
{
struct ip_mreq imr;
- imr.imr_interface.s_addr = htonl(INADDR_ANY);
- imr.imr_multiaddr.s_addr = i_mc_group;
+ imr.imr_interface.s_addr = INADDR_ANY;
+ imr.imr_multiaddr.s_addr = sock.sin_addr.s_addr;
if( setsockopt( p_input->i_handle, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char*)&imr, sizeof(struct ip_mreq) ) == -1 )
{
* netutils.c: various network functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: netutils.c,v 1.46 2001/11/16 00:29:52 stef Exp $
+ * $Id: netutils.c,v 1.47 2001/11/21 16:47:46 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr>
char * psz_broadcast )
{
#if defined( SYS_BEOS )
- intf_ErrMsg( "error: channel changing is not yet supported under BeOS" );
+ intf_ErrMsg( "error: networking is not yet supported under BeOS" );
return( 1 );
#else
- char psz_hostname[INPUT_MAX_SOURCE_LENGTH];
- struct hostent * p_hostent;
-
/* Reset struct */
memset( p_socket, 0, sizeof( struct sockaddr_in ) );
p_socket->sin_family = AF_INET; /* family */
p_socket->sin_port = htons( i_port );
if( psz_broadcast == NULL )
{
- /* Try to get our own IP */
- if( gethostname( psz_hostname, sizeof(psz_hostname) ) )
- {
- intf_ErrMsg( "BuildLocalAddr : unable to resolve local name : %s",
- strerror( errno ) );
- return( -1 );
- }
-
+ p_socket->sin_addr.s_addr = INADDR_ANY;
}
else
{
- /* 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 );
- }
+ struct hostent * p_hostent;
- /* Try to convert address directly from in_addr - this will work if
- * psz_in_addr is dotted decimal. */
+ /* Try to convert address directly from in_addr - this will work if
+ * psz_broadcast is dotted decimal. */
#ifdef HAVE_ARPA_INET_H
- if( !inet_aton( psz_hostname, &p_socket->sin_addr) )
+ if( !inet_aton( psz_broadcast, &p_socket->sin_addr) )
#else
- if( (p_socket->sin_addr.s_addr = inet_addr( psz_hostname )) == -1 )
+ if( (p_socket->sin_addr.s_addr = inet_addr( psz_broadcast )) == -1 )
#endif
- {
- /* We have a fqdn, try to find its address */
- if ( (p_hostent = gethostbyname( psz_hostname )) == NULL )
{
- intf_ErrMsg( "BuildLocalAddr: unknown host %s", psz_hostname );
- return( -1 );
+ /* We have a fqdn, try to find its address */
+ if ( (p_hostent = gethostbyname( psz_broadcast )) == NULL )
+ {
+ intf_ErrMsg( "BuildLocalAddr: unknown host %s", psz_broadcast );
+ return( -1 );
+ }
+
+ /* Copy the first address of the host in the socket address */
+ memcpy( &p_socket->sin_addr, p_hostent->h_addr_list[0],
+ p_hostent->h_length );
}
-
- /* Copy the first address of the host in the socket address */
- memcpy( &p_socket->sin_addr, p_hostent->h_addr_list[0],
- p_hostent->h_length );
}
return( 0 );
#endif
int network_BuildRemoteAddr( struct sockaddr_in * p_socket, char * psz_server )
{
#if defined( SYS_BEOS )
- intf_ErrMsg( "error: channel changing is not yet supported under BeOS" );
+ intf_ErrMsg( "error: networking is not yet supported under BeOS" );
return( 1 );
#else