[Freeswitch-dev] multicast paging

Robert Buchholz buchholr at gmail.com
Sat Sep 19 12:40:05 PDT 2009


I am new to freeswitch, and was experimenting with the multicast paging.  I
found that the TTL of 1 is a great limitation to what I am trying to do.  I
have modified the source code of mod_esf.c to allow the TTL to be modified
as an argument like the IP and ports.  I am submitting the diff file for
comment and possible inclusion in future releases.

I have tried to follow the format and style of programming.  I have compiled
and run this successfully on both FreeBSD 7.2 and Fedora 11.

Please let me know what you think.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20090919/ef524e3e/attachment.html 
-------------- next part --------------
Index: src/mod/applications/mod_esf/mod_esf.c
===================================================================
--- src/mod/applications/mod_esf/mod_esf.c	(revision 14842)
+++ src/mod/applications/mod_esf/mod_esf.c	(working copy)
@@ -80,8 +80,8 @@
 	const char *esf_broadcast_ip = NULL, *var;
 	switch_codec_implementation_t read_impl = {0};
     switch_core_session_get_read_impl(session, &read_impl);
+	int mcast_ttl = 1;
 
-
 	if (!switch_strlen_zero((char *) data)) {
 		mydata = switch_core_session_strdup(session, data);
 		assert(mydata != NULL);
@@ -104,6 +104,13 @@
 		if (!switch_strlen_zero(argv[2])) {
 			mcast_control_port = (switch_port_t) atoi(argv[2]);
 		}
+		
+		if (!switch_strlen_zero(argv[3])) {
+			mcast_ttl = atoi(argv[3]);
+			if (mcast_ttl < 1 || mcast_ttl > 255) {
+				mcast_ttl = 1;
+			}
+		}
 	}
 
 	if (switch_true(switch_channel_get_variable(channel, SWITCH_BYPASS_MEDIA_VARIABLE))) {
@@ -128,6 +135,11 @@
 		goto fail;
 	}
 
+	if (switch_mcast_hops(socket, mcast_ttl) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Mutlicast TTL set failed\n");
+		goto fail;
+	}
+
 	if (switch_sockaddr_info_get(&control_packet_addr, mcast_ip, SWITCH_UNSPEC,
 								 mcast_control_port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error 3\n");


More information about the FreeSWITCH-dev mailing list