diff --git a/conf/sip_profiles/internal.xml b/conf/sip_profiles/internal.xml index b8390c7..07c1f66 100644 --- a/conf/sip_profiles/internal.xml +++ b/conf/sip_profiles/internal.xml @@ -173,6 +173,7 @@ + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 0a2f672..ae0ab1a 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -204,6 +204,7 @@ typedef enum { PFLAG_BLIND_AUTH, PFLAG_WORKER_RUNNING, PFLAG_UNREG_OPTIONS_FAIL, + PFLAG_DEAD_OPTIONS_FAIL, PFLAG_DISABLE_TIMER, PFLAG_ENABLE_RFC5626, PFLAG_DISABLE_100REL, diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 8b362b6..a37c79c 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3265,6 +3265,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } else { sofia_clear_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL); } + } else if (!strcasecmp(var, "mark-dead-on-options-fail")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_DEAD_OPTIONS_FAIL); + } else { + sofia_clear_pflag(profile, PFLAG_DEAD_OPTIONS_FAIL); + } } else if (!strcasecmp(var, "require-secure-rtp")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_SECURE); @@ -4214,6 +4220,10 @@ switch_status_t config_sofia(int reload, char *profile_name) if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL); } + } else if (!strcasecmp(var, "mark-dead-on-options-fail")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_DEAD_OPTIONS_FAIL); + } } else if (!strcasecmp(var, "require-secure-rtp")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_SECURE); @@ -4736,6 +4746,14 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu gateway->ping = switch_epoch_time_now(NULL) + gateway->ping_freq; sofia_reg_release_gateway(gateway); gateway->pinging = 0; + } else if (sofia_test_pflag(profile, PFLAG_DEAD_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) { + char *sql; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Marking registration '%s@%s' DEAD due to options failure\n", + sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); + + sql = switch_mprintf("update sip_registrations set status='Dead' where sip_user='%s' and sip_host='%s'", + sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); + sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); } else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) { char *sql; time_t now = switch_epoch_time_now(NULL);