
On Wed, Jan 23, 2002, Eric Doutreleau wrote:
> It would be nice if it was possible to specifty the ttl value for
> the multicast broadcasting ideally on the vls.cfg file.
> 
> To set the ttl in C
> u_char ttl;
> setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, 
> &ttl, sizeof(ttl));

Could you please try the attached patch and tell me if it works for
multicast too ? And if it doesn't then put IP_MULTICAST_TTL instead of
IP_TTL in src/modules/netchannel/netoutput.cpp:130.

The option added to the channel configuration is "TTL" (case sensitive):

BEGIN "blabla"
  ...
  TTL = "12"
END

If it works I'll commit it into the CVS.

-- 
Arnaud de Bossoreille de Ribou - http://www.via.ecp.fr/~bozo/


-- Attached file included as plaintext by Listar --

Index: src/modules/netchannel/netchannel.cpp
===================================================================
RCS file: /var/cvs/videolan/vls/src/modules/netchannel/netchannel.cpp,v
retrieving revision 1.3
diff -u -r1.3 netchannel.cpp
--- src/modules/netchannel/netchannel.cpp	2001/11/29 16:11:42	1.3
+++ src/modules/netchannel/netchannel.cpp	2002/01/24 14:10:59
@@ -83,8 +83,12 @@
   C_String strDstHost = pApp->GetSetting(m_strName+".DstHost", "239.0.0.3");
   C_String strDstPort = pApp->GetSetting(m_strName+".DstPort", "1234");
 
+  C_String strTTL = pApp->GetSetting(m_strName+".TTL", "0");
+  unsigned char iTTL = strTTL.ToInt();
+
   m_pOutput = new C_NetOutput(strInterface,
-                              strSrcHost, strSrcPort, strDstHost, strDstPort);
+                              strSrcHost, strSrcPort, strDstHost, strDstPort,
+                              iTTL);
 }
 
 
Index: src/modules/netchannel/netoutput.cpp
===================================================================
RCS file: /var/cvs/videolan/vls/src/modules/netchannel/netoutput.cpp,v
retrieving revision 1.1
diff -u -r1.1 netoutput.cpp
--- src/modules/netchannel/netoutput.cpp	2001/11/22 01:51:12	1.1
+++ src/modules/netchannel/netoutput.cpp	2002/01/24 14:10:59
@@ -51,12 +51,15 @@
 //------------------------------------------------------------------------------
 C_NetOutput::C_NetOutput(const C_String& strInterface,
                          const C_String& strSrcHost, const C_String& strSrcPort,
-                         const C_String& strDstHost, const C_String& strDstPort)
+                         const C_String& strDstHost, const C_String& strDstPort,
+                         unsigned char iTTL)
                 : C_Output(TS_IN_ETHER), m_cSocketBuff(TS_IN_ETHER),
                   m_strInterface(strInterface),
                   m_strSrcHost(strSrcHost), m_strSrcPort(strSrcPort),
                   m_strDstHost(strDstHost), m_strDstPort(strDstPort)
 {
+  m_iTTL = iTTL;
+
   // Init the buffer
   for(int iIndex = 0; iIndex < TS_IN_ETHER; iIndex++)
     m_cSocketBuff.SetSlotSize(iIndex, TS_PACKET_LEN);
@@ -121,6 +124,10 @@
                           sizeof(sInterface));
     }
 #endif
+
+    // Set the Time To Live value if != 0
+    if(m_iTTL)
+      m_cSocket.SetOption(IPPROTO_IP, IP_TTL, &m_iTTL, sizeof(m_iTTL));
 
     // Bind it to the local address
     m_cSocket.Bind(m_strSrcHost, m_strSrcPort);
Index: src/modules/netchannel/netoutput.h
===================================================================
RCS file: /var/cvs/videolan/vls/src/modules/netchannel/netoutput.h,v
retrieving revision 1.1
diff -u -r1.1 netoutput.h
--- src/modules/netchannel/netoutput.h	2001/11/22 01:51:12	1.1
+++ src/modules/netchannel/netoutput.h	2002/01/24 14:10:59
@@ -43,7 +43,8 @@
  public:
   C_NetOutput(const C_String& strInterface,
               const C_String& strSrcHost, const C_String& strSrcPort,
-              const C_String& strDstHost, const C_String& strDstPort);
+              const C_String& strDstHost, const C_String& strDstPort,
+              unsigned char iTTL);
   virtual ~C_NetOutput();
 
   virtual void OnInit();
@@ -61,6 +62,8 @@
   C_String m_strSrcPort;
   C_String m_strDstHost;
   C_String m_strDstPort;
+  unsigned char m_iTTL;
+
   C_InetAddr m_cOutputInetAddr;
 #ifdef BUGGY_VLC
   byte m_ByteBuff[TS_PACKET_LEN * TS_IN_ETHER];


-- 
This is the vls-devel mailing-list, see http://www.videolan.org/vls-devel/
To unsubscribe, please read http://www.videolan.org/lists.html

