diff --git a/conf/sip_profiles/internal.xml b/conf/sip_profiles/internal.xml index 50833bfbec..93558a3584 100644 --- a/conf/sip_profiles/internal.xml +++ b/conf/sip_profiles/internal.xml @@ -42,6 +42,26 @@ + + + + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 5bc1b4e8a2..323702e3c5 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -3174,6 +3174,17 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t goto done; } + if (!strcasecmp(argv[1], "watchdog")) { + if (argc > 2) { + int value = switch_true(argv[2]); + profile->watchdog_enabled = value; + stream->write_function(stream, "%s sip debugging on %s", value ? "Enabled" : "Disabled", profile->name); + } else { + stream->write_function(stream, "Usage: sofia profile watchdog \n"); + } + goto done; + } + if (!strcasecmp(argv[1], "gwlist")) { int up = 1; @@ -3510,12 +3521,14 @@ SWITCH_STANDARD_API(sofia_function) "[register|unregister] [|all]|" "killgw |" "[stun-auto-disable|stun-enabled] [true|false]]|" - "siptrace [on|off]\n" + "siptrace |" + "watchdog \n" "sofia status|xmlstatus profile [ reg ] | [ pres ] | [ user ]\n" "sofia status|xmlstatus gateway \n" "sofia loglevel [0-9]\n" "sofia tracelevel \n" - "sofa global siptrace [on|off]\n" + "sofia global siptrace |" + "watchdog \n" "--------------------------------------------------------------------------------\n"; if (session) { @@ -3572,21 +3585,30 @@ SWITCH_STANDARD_API(sofia_function) stream->write_function(stream, "%s", usage_string); goto done; } else if (!strcasecmp(argv[0], "global")) { - int on = -1; + int ston = -1; + int wdon = -1; if (argc > 1) { if (!strcasecmp(argv[1], "siptrace")) { if (argc > 2) { - on = switch_true(argv[2]); + ston = switch_true(argv[2]); + } + } + if (!strcasecmp(argv[1], "watchdog")) { + if (argc > 2) { + wdon = switch_true(argv[2]); } } } - if (on != -1) { - sofia_glue_global_siptrace(on); - stream->write_function(stream, "+OK Global siptrace %s", on ? "on" : "off"); + if (ston != -1) { + sofia_glue_global_siptrace(ston); + stream->write_function(stream, "+OK Global siptrace %s", ston ? "on" : "off"); + } else if (wdon != -1) { + sofia_glue_global_watchdog(wdon); + stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off"); } else { - stream->write_function(stream, "-ERR Usage: siptrace on|off"); + stream->write_function(stream, "-ERR Usage: siptrace |watchdog "); } goto done; @@ -4668,6 +4690,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_console_set_complete("add sofia tracelevel ::[console:alert:crit:err:warning:notice:info:debug"); switch_console_set_complete("add sofia global siptrace ::[on:off"); + switch_console_set_complete("add sofia global watchdog ::[on:off"); switch_console_set_complete("add sofia profile"); switch_console_set_complete("add sofia profile restart all"); @@ -4683,6 +4706,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_console_set_complete("add sofia profile ::sofia::list_profiles killgw ::sofia::list_profile_gateway"); switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace on"); switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace off"); + switch_console_set_complete("add sofia profile ::sofia::list_profiles watchdog on"); + switch_console_set_complete("add sofia profile ::sofia::list_profiles watchdog off"); switch_console_set_complete("add sofia profile ::sofia::list_profiles gwlist up"); switch_console_set_complete("add sofia profile ::sofia::list_profiles gwlist down"); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index ea62398f8a..cf4b9a3759 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -566,6 +566,7 @@ struct sofia_profile { switch_time_t last_root_step; uint32_t step_timeout; uint32_t event_timeout; + int watchdog_enabled; }; struct private_object { @@ -1020,6 +1021,7 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt); switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host); switch_bool_t sofia_glue_profile_exists(const char *key); void sofia_glue_global_siptrace(switch_bool_t on); +void sofia_glue_global_watchdog(switch_bool_t on); void sofia_glue_proxy_codec(switch_core_session_t *session, const char *r_sdp); switch_status_t sofia_glue_sdp_map(const char *r_sdp, switch_event_t **fmtp, switch_event_t **pt); void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index aa4c5175b3..0598624c63 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1326,7 +1326,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread } } - if (fail) { + if (profile->watchdog_enabled && fail) { int arg = 1; switch_session_ctl_t command = SCSC_SHUTDOWN_NOW; @@ -2327,9 +2327,11 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } else { sofia_clear_pflag(profile, PFLAG_DEL_SUBS_ON_REG); } - } else if (!strcasecmp(var, "watchdog_step_timeout")) { + } else if (!strcasecmp(var, "watchdog-enabled")) { + profile->watchdog_enabled = switch_true(val); + } else if (!strcasecmp(var, "watchdog-step-timeout")) { profile->step_timeout = (unsigned long) atol(val); - } else if (!strcasecmp(var, "watchdog_event_timeout")) { + } else if (!strcasecmp(var, "watchdog-event-timeout")) { profile->event_timeout = (unsigned long) atol(val); } else if (!strcasecmp(var, "in-dialog-chat")) { if (switch_true(val)) { @@ -3011,9 +3013,11 @@ switch_status_t config_sofia(int reload, char *profile_name) } else { sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL); } - } else if (!strcasecmp(var, "watchdog_step_timeout")) { + } else if (!strcasecmp(var, "watchdog-enabled")) { + profile->watchdog_enabled = switch_true(val); + } else if (!strcasecmp(var, "watchdog-step-timeout")) { profile->step_timeout = atoi(val); - } else if (!strcasecmp(var, "watchdog_event_timeout")) { + } else if (!strcasecmp(var, "watchdog-event-timeout")) { profile->event_timeout = atoi(val); } else if (!strcasecmp(var, "in-dialog-chat")) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 9d6cff78e7..7464a42825 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -4752,6 +4752,26 @@ void sofia_glue_global_siptrace(switch_bool_t on) } +void sofia_glue_global_watchdog(switch_bool_t on) +{ + switch_hash_index_t *hi; + const void *var; + void *val; + sofia_profile_t *pptr; + + switch_mutex_lock(mod_sofia_globals.hash_mutex); + if (mod_sofia_globals.profile_hash) { + for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &var, NULL, &val); + if ((pptr = (sofia_profile_t *) val)) { + pptr->watchdog_enabled = (on ? 1 : 0); + } + } + } + switch_mutex_unlock(mod_sofia_globals.hash_mutex); + +} + void sofia_glue_del_profile(sofia_profile_t *profile) { sofia_gateway_t *gp;