}
}
+ goto done;
+ } else if (!strcasecmp(argv[1], "startgw")) {
+ if (argc < 3) {
+ stream->write_function(stream, "-ERR missing gw name\n");
+ goto done;
+ }
+
+ switch_xml_reload(&err);
+ stream->write_function(stream, "Reload XML [%s]\n", err);
+
+ if (config_gateway(profile->name, argv[2]) == SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "+OK start gateway %s complete\n", argv[2]);
+ } else {
+ stream->write_function(stream, "-ERR cannot add gateway %s for profile %s\n", argv[2], profile->name);
+ }
+
goto done;
}
switch_console_set_complete("add sofia profile ::sofia::list_profiles stop wait");
switch_console_set_complete("add sofia profile ::sofia::list_profiles flush_inbound_reg reboot");
switch_console_set_complete("add sofia profile ::sofia::list_profiles ::[register:unregister all");
- switch_console_set_complete("add sofia profile ::sofia::list_profiles ::[register:unregister:killgw ::sofia::list_profile_gateway");
+ switch_console_set_complete("add sofia profile ::sofia::list_profiles ::[register:unregister:killgw:startgw ::sofia::list_profile_gateway");
switch_console_set_complete("add sofia profile ::sofia::list_profiles killgw _all_");
+ switch_console_set_complete("add sofia profile ::sofia::list_profiles startgw _all_");
switch_console_set_complete("add sofia profile ::sofia::list_profiles ::[siptrace:capture:watchdog ::[on:off");
switch_console_set_complete("add sofia profile ::sofia::list_profiles gwlist ::[up:down");
extern su_log_t su_log_default[];
static void config_sofia_profile_urls(sofia_profile_t * profile);
-static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag);
+static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag, const char *gwname);
static void parse_domain_tag(sofia_profile_t *profile, switch_xml_t x_domain_tag, const char *dname, const char *parse, const char *alias);
void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
if ((xprofile = switch_xml_find_child(xprofiles, "profile", "name", profile->name))) {
if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
- parse_gateways(profile, gateways_tag);
+ parse_gateways(profile, gateways_tag, NULL);
}
if ((domains_tag = switch_xml_child(xprofile, "domains"))) {
}
}
-static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
+static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag, const char *gwname)
{
switch_xml_t gateway_tag, param = NULL, x_params, gw_subs_tag;
sofia_gateway_t *gp;
goto skip;
}
+ if (gwname && strcmp(gwname, name)) {
+ free(pkey);
+ goto skip;
+ }
+
switch_mutex_lock(mod_sofia_globals.hash_mutex);
if ((gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, name)) && (gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, pkey)) && !gp->deleted) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", name);
/* Backwards Compatibility */
for (ut = switch_xml_child(x_domain_tag, "user"); ut; ut = ut->next) {
if (((gateways_tag = switch_xml_child(ut, "gateways")))) {
- parse_gateways(profile, gateways_tag);
+ parse_gateways(profile, gateways_tag, NULL);
}
}
/* New Method with <groups> tags and users are now inside a <users> tag */
for (uts = switch_xml_child(gt, "users"); uts; uts = uts->next) {
for (ut = switch_xml_child(uts, "user"); ut; ut = ut->next) {
if (((gateways_tag = switch_xml_child(ut, "gateways")))) {
- parse_gateways(profile, gateways_tag);
+ parse_gateways(profile, gateways_tag, NULL);
}
}
}
return SWITCH_STATUS_SUCCESS;
}
+switch_status_t config_gateway(const char *profile_name, const char *gateway_name)
+{
+ switch_xml_t cfg, xml = NULL, xprofiles, xprofile, gateways_tag;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ sofia_profile_t *profile = NULL;
+ switch_event_t *params = NULL;
+ const char *cf = "sofia.conf";
+
+ if (zstr(profile_name) || !(profile = sofia_glue_find_profile(profile_name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Profile [%s] does not exist.\n", profile_name);
+ status = SWITCH_STATUS_FALSE;
+ return status;
+ }
+
+ switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
+ switch_assert(params);
+ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", profile_name);
+ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "reconfig", "true");
+ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "gateway", gateway_name);
+
+ if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", gateway_name);
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
+
+ if ((xprofiles = switch_xml_child(cfg, "profiles"))) {
+ if ((xprofile = switch_xml_find_child(xprofiles, "profile", "name", profile->name))) {
+ if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
+ parse_gateways(profile, gateways_tag, strcmp(gateway_name, "_all_") ? gateway_name : NULL);
+ }
+ }
+ }
+
+ status = SWITCH_STATUS_SUCCESS;
+
+done:
+
+ if (profile) sofia_glue_release_profile(profile);
+ if (xml) switch_xml_free(xml);
+
+ switch_event_destroy(¶ms);
+
+ return status;
+}
switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
{
}
if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
- parse_gateways(profile, gateways_tag);
+ parse_gateways(profile, gateways_tag, NULL);
}
status = SWITCH_STATUS_SUCCESS;