mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
Make ttl configurable for event_multicast
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13802 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
8b6143fb38
commit
3c2d4f9912
@ -55,6 +55,7 @@ static struct {
|
|||||||
uint8_t event_list[SWITCH_EVENT_ALL + 1];
|
uint8_t event_list[SWITCH_EVENT_ALL + 1];
|
||||||
int running;
|
int running;
|
||||||
switch_event_node_t *node;
|
switch_event_node_t *node;
|
||||||
|
uint8_t ttl;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address);
|
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address);
|
||||||
@ -74,6 +75,8 @@ static switch_status_t load_config(void)
|
|||||||
globals.host_hash = switch_hashfunc_default(globals.hostname, &hlen);
|
globals.host_hash = switch_hashfunc_default(globals.hostname, &hlen);
|
||||||
globals.key_count = 0;
|
globals.key_count = 0;
|
||||||
|
|
||||||
|
globals.ttl = 1;
|
||||||
|
|
||||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
|
||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
@ -95,7 +98,15 @@ static switch_status_t load_config(void)
|
|||||||
set_global_bindings(val);
|
set_global_bindings(val);
|
||||||
} else if (!strcasecmp(var, "port")) {
|
} else if (!strcasecmp(var, "port")) {
|
||||||
globals.port = (switch_port_t) atoi(val);
|
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 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_event_multicast_load)
|
|||||||
return SWITCH_STATUS_TERM;
|
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) {
|
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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bind Error\n");
|
||||||
switch_socket_close(globals.udp_socket);
|
switch_socket_close(globals.udp_socket);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user