From 395b7a97997496ca0758df64521d173a24593940 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 12:59:33 -0600 Subject: [PATCH] FS-4882 --resolve --- src/mod/endpoints/mod_sofia/sofia.c | 4 ++-- src/mod/endpoints/mod_sofia/sofia_reg.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index ed3428555e..a00a0d21bd 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4781,10 +4781,10 @@ 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_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && sip && sip->sip_to) { + } else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && sip && sip->sip_to && strchr(sip->sip_call_id->i_id, '_')) { char *sql; time_t now = switch_epoch_time_now(NULL); - const char *call_id = sip->sip_call_id->i_id; + const char *call_id = strchr(sip->sip_call_id->i_id, '_') + 1; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n", sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 507ace4391..f3d3bb205b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -557,17 +557,23 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames { sofia_profile_t *profile = (sofia_profile_t *) pArg; nua_handle_t *nh; - char to[512] = ""; + char to[512] = "", call_id[512] = ""; sofia_destination_t *dst = NULL; + switch_uuid_t uuid; switch_snprintf(to, sizeof(to), "sip:%s@%s", argv[1], argv[2]); + // create call-id for OPTIONS in the form "_" + switch_uuid_get(&uuid); + switch_uuid_format(call_id, &uuid); + strcat(call_id, "_"); + strncat(call_id, argv[0], sizeof(call_id) - SWITCH_UUID_FORMATTED_LENGTH - 2); + dst = sofia_glue_get_destination(argv[3]); switch_assert(dst); nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url), - TAG_END()); - //SIPTAG_CALL_ID_STR(argv[0]), TAG_END()); + SIPTAG_CALL_ID_STR(call_id), TAG_END()); nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_options(nh, NTATAG_SIP_T2(5000),