]> git.sesse.net Git - vlc/commitdiff
For people who have several network interfaces, added a --iface-addr option
authorChristophe Massiot <massiot@videolan.org>
Tue, 1 Oct 2002 22:29:09 +0000 (22:29 +0000)
committerChristophe Massiot <massiot@videolan.org>
Tue, 1 Oct 2002 22:29:09 +0000 (22:29 +0000)
to select which interface to use for multicast sockets.

modules/misc/network/ipv4.c
src/libvlc.h

index 8af661fa1a9c1727989a0b1cd8c9e128d006c288..1c72b973b81325aa01f26de2a0fc0f1db14a9a40 100644 (file)
@@ -2,7 +2,7 @@
  * ipv4.c: IPv4 network abstraction layer
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: ipv4.c,v 1.3 2002/08/08 22:28:22 sam Exp $
+ * $Id: ipv4.c,v 1.4 2002/10/01 22:29:08 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Mathias Kretschmer <mathias@research.att.com>
@@ -240,15 +240,25 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
     if( IN_MULTICAST( ntohl(sock.sin_addr.s_addr) ) )
     {
         struct ip_mreq imr;
-        imr.imr_interface.s_addr = INADDR_ANY;
+        char * psz_if_addr = config_GetPsz( p_this, "iface-addr" );
         imr.imr_multiaddr.s_addr = sock.sin_addr.s_addr;
 #else
     if( IN_MULTICAST( ntohl(inet_addr(psz_bind_addr) ) ) )
     {
         struct ip_mreq imr;
-        imr.imr_interface.s_addr = INADDR_ANY;
+        char * psz_if_addr = config_GetPsz( p_this, "iface-addr" );
         imr.imr_multiaddr.s_addr = inet_addr(psz_bind_addr);
-#endif                
+#endif
+        if ( *psz_if_addr && inet_addr(psz_if_addr) != -1 )
+        {
+            imr.imr_interface.s_addr = inet_addr(psz_if_addr);
+        }
+        else
+        {
+            imr.imr_interface.s_addr = INADDR_ANY;
+        }
+        free( psz_if_addr );
+
         if( setsockopt( i_handle, IPPROTO_IP, IP_ADD_MEMBERSHIP,
                         (char*)&imr, sizeof(struct ip_mreq) ) == -1 )
         {
index 09328d6df18af85034c3b614b09974629ee06296..f2b34e05f7311f683d8ba2af384da57613ed7979 100644 (file)
@@ -2,7 +2,7 @@
  * libvlc.h: main libvlc header
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.h,v 1.15 2002/09/16 20:46:38 massiot Exp $
+ * $Id: libvlc.h,v 1.16 2002/10/01 22:29:09 massiot Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
     "If you have several interfaces on your Linux machine and use the " \
     "VLAN solution, you may indicate here which interface to use.")
 
+#define IFACE_ADDR_TEXT N_("network interface address")
+#define IFACE_ADDR_LONGTEXT N_( \
+    "If you have several interfaces on your machine and use the " \
+    "multicast solution, you will probably have to indicate the IP address " \
+    "of your multicasting interface here.")    
+
 #define INPUT_PROGRAM_TEXT N_("choose program (SID)")
 #define INPUT_PROGRAM_LONGTEXT N_( \
     "Choose the program to select by giving its Service ID.")
@@ -392,6 +398,7 @@ vlc_module_begin();
                  CHAN_PORT_TEXT, CHAN_PORT_LONGTEXT );
     add_integer( "mtu", 1500, NULL, MTU_TEXT, MTU_LONGTEXT );
     add_string( "iface", "eth0", NULL, IFACE_TEXT, IFACE_LONGTEXT );
+    add_string( "iface-addr", "", NULL, IFACE_ADDR_TEXT, IFACE_ADDR_LONGTEXT );
 
     add_integer( "program", 0, NULL,
                  INPUT_PROGRAM_TEXT, INPUT_PROGRAM_LONGTEXT );