]> 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.

plugins/network/ipv4.c
src/interface/main.c

index c5066d78644db22df42411b47633db5b50133578..697559c333f76d8751b30a5293a4fac7a80c8892 100644 (file)
@@ -2,7 +2,7 @@
  * ipv4.c: IPv4 network abstraction layer
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: ipv4.c,v 1.12.2.1 2002/07/19 21:12:18 massiot Exp $
+ * $Id: ipv4.c,v 1.12.2.2 2002/10/01 22:26:39 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Mathias Kretschmer <mathias@research.att.com>
@@ -264,15 +264,25 @@ static int OpenUDP( 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_GetPszVariable( "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_GetPszVariable( "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 a2d0e92a80cb515d366932cde97e3473d1e1bfee..90dee092dd84c4ff1ee822ade79a70c3c959c141 100644 (file)
@@ -4,7 +4,7 @@
  * and spawn threads.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: main.c,v 1.195.2.7 2002/08/07 21:35:24 massiot Exp $
+ * $Id: main.c,v 1.195.2.8 2002/10/01 22:26:39 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.")
@@ -410,6 +416,7 @@ ADD_STRING  ( "channel-server", "localhost", NULL, CHAN_SERV_TEXT, CHAN_SERV_LON
 ADD_INTEGER ( "channel-port", 6010, NULL, 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 )
 ADD_INTEGER ( "audio-type", -1, NULL, INPUT_AUDIO_TEXT, INPUT_AUDIO_LONGTEXT )