Skip to content

Commit

Permalink
[mod_sofia] Set sip_100_uepoch channel variable on initial 100 trying…
Browse files Browse the repository at this point in the history
… response.
  • Loading branch information
andywolk committed Oct 23, 2021
1 parent 66a9206 commit d2e8a77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/mod/endpoints/mod_sofia/mod_sofia.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 16 additions & 9 deletions src/mod/endpoints/mod_sofia/sofia.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

1 comment on commit d2e8a77

@andywolk
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.