feat(mod_sofia): read sip_reason in sofia_handle_sip_r_invite

This commit is contained in:
Antoine Rose 2024-05-30 17:48:30 +02:00
parent 218a00e2e9
commit bcd3258555
1 changed files with 12 additions and 0 deletions

View File

@ -6599,6 +6599,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
tagi_t tags[]) tagi_t tags[])
{ {
char *call_info = NULL; char *call_info = NULL;
char *reason_header = NULL;
if (sip && session) { if (sip && session) {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
const char *uuid; const char *uuid;
@ -6665,6 +6666,14 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
switch_channel_set_variable_partner(channel, "sip_invite_failure_phrase", NULL); switch_channel_set_variable_partner(channel, "sip_invite_failure_phrase", NULL);
} }
if (sip->sip_reason) {
reason_header = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_reason);
if (!zstr(reason_header)) {
switch_channel_set_variable(channel, "sip_reason", reason_header);
switch_channel_set_variable_partner(channel, "sip_reason", reason_header);
}
}
if (status >= 400 && sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850") if (status >= 400 && sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
|| !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH") || !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH")
|| !strcasecmp(sip->sip_reason->re_protocol, profile->sdp_username)) && sip->sip_reason->re_cause) { || !strcasecmp(sip->sip_reason->re_protocol, profile->sdp_username)) && sip->sip_reason->re_cause) {
@ -7232,6 +7241,9 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
if (call_info) { if (call_info) {
su_free(nua_handle_home(nh), call_info); su_free(nua_handle_home(nh), call_info);
} }
if (reason_header) {
su_free(nua_handle_home(nh), reason_header);
}
if (!session && (status == 180 || status == 183 || status == 200)) { if (!session && (status == 180 || status == 183 || status == 200)) {
/* nevermind */ /* nevermind */