[Freeswitch-svn] [commit] r13802 - freeswitch/trunk/src/mod/event_handlers/mod_event_multicast
FreeSWITCH SVN
andrew at freeswitch.org
Tue Jun 16 21:15:45 PDT 2009
Author: andrew
Date: Tue Jun 16 23:15:45 2009
New Revision: 13802
Log:
Make ttl configurable for event_multicast
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c Tue Jun 16 23:15:45 2009
@@ -55,6 +55,7 @@
uint8_t event_list[SWITCH_EVENT_ALL + 1];
int running;
switch_event_node_t *node;
+ uint8_t ttl;
} globals;
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address);
@@ -74,6 +75,8 @@
globals.host_hash = switch_hashfunc_default(globals.hostname, &hlen);
globals.key_count = 0;
+ globals.ttl = 1;
+
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
@@ -95,7 +98,15 @@
set_global_bindings(val);
} else if (!strcasecmp(var, "port")) {
globals.port = (switch_port_t) atoi(val);
+ } else if (!strcasecmp(var, "ttl")) {
+ int ttl = atoi(val);
+ if ((ttl && ttl <= 255) || !strcmp(val, "0")) {
+ globals.ttl = (uint8_t) ttl;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid ttl '%s' specified, using default of 1\n", val);
+ }
}
+
}
}
@@ -222,6 +233,12 @@
return SWITCH_STATUS_TERM;
}
+ if (switch_mcast_hops(globals.udp_socket, globals.ttl) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set ttl to '%d'\n", globals.ttl);
+ switch_socket_close(globals.udp_socket);
+ return SWITCH_STATUS_TERM;
+ }
+
if (switch_socket_bind(globals.udp_socket, globals.addr) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bind Error\n");
switch_socket_close(globals.udp_socket);
More information about the Freeswitch-svn
mailing list