]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Set sip_100_uepoch channel variable on initial 100 trying response.
authorAndrey Volk <andywolk@gmail.com>
Tue, 27 Oct 2020 16:14:51 +0000 (20:14 +0400)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:00:37 +0000 (22:00 +0300)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index 9d0d150354377c915a4017b7a7be1015553f7bd5..6e118e1fe325867f9d97c67508f4cd5a5cf5af7b 100644 (file)
@@ -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;
index a71678dd10c49d9358b9da019e9259b8732c5df5..bb5b969552e5822143664ab0fd23105ad25ab962 100644 (file)
@@ -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);