From d2e8a775b04090f1745442c2fe9e7c3a513bfb67 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Tue, 27 Oct 2020 20:14:51 +0400 Subject: [PATCH] [mod_sofia] Set sip_100_uepoch channel variable on initial 100 trying response. --- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 9d0d150354..6e118e1fe3 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -363,6 +363,7 @@ typedef enum { TFLAG_PASS_ACK, TFLAG_KEEPALIVE, TFLAG_SKIP_EARLY, + TFLAG_100_UEPOCH_SET, /* No new flags below this line */ TFLAG_MAX } TFLAGS; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index a71678dd10..bb5b969552 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -6597,6 +6597,22 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status switch_caller_profile_t *caller_profile = NULL; int has_t38 = 0; + if (status == 100 && !sofia_test_flag(tech_pvt, TFLAG_100_UEPOCH_SET)) { + sofia_set_flag(tech_pvt, TFLAG_100_UEPOCH_SET); + switch_channel_set_variable_printf(channel, "sip_100_uepoch", "%" SWITCH_TIME_T_FMT, switch_time_now()); + } + + if (de && de->data && de->data->e_msg) { + sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port); + + switch_channel_set_variable_printf(channel, "sip_local_network_addr", "%s", profile->extsipip ? profile->extsipip : profile->sipip); + switch_channel_set_variable(channel, "sip_reply_host", network_ip); + switch_channel_set_variable_printf(channel, "sip_reply_port", "%d", network_port); + + switch_channel_set_variable_printf(channel, "sip_network_ip", "%s", network_ip); + switch_channel_set_variable_printf(channel, "sip_network_port", "%d", network_port); + } + switch_channel_clear_flag(channel, CF_REQ_MEDIA); if (status < 200) { @@ -6644,15 +6660,6 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote Reason: %d\n", tech_pvt->q850_cause); } - sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port); - - switch_channel_set_variable_printf(channel, "sip_local_network_addr", "%s", profile->extsipip ? profile->extsipip : profile->sipip); - switch_channel_set_variable(channel, "sip_reply_host", network_ip); - switch_channel_set_variable_printf(channel, "sip_reply_port", "%d", network_port); - - switch_channel_set_variable_printf(channel, "sip_network_ip", "%s", network_ip); - switch_channel_set_variable_printf(channel, "sip_network_port", "%d", network_port); - if ((caller_profile = switch_channel_get_caller_profile(channel)) && !zstr(network_ip) && (zstr(caller_profile->network_addr) || strcmp(caller_profile->network_addr, network_ip))) { caller_profile->network_addr = switch_core_strdup(caller_profile->pool, network_ip);