Skip to content
Snippets Groups Projects
Commit 2d1b11cb authored by Grzegorz Sluja's avatar Grzegorz Sluja Committed by Grzegorz Sluja
Browse files

Use correct URI schema in Referred-By and Refer-To header fields in call transfer

parent 9e39d235
No related branches found
No related tags found
No related merge requests found
...@@ -2175,7 +2175,16 @@ static void transfer_refer(struct ast_sip_session *session, const char *target) ...@@ -2175,7 +2175,16 @@ static void transfer_refer(struct ast_sip_session *session, const char *target)
chan_name, target, replaces); chan_name, target, replaces);
} }
snprintf(referto, sizeof(referto), "<sip:%s@%s%s>", target, session->endpoint->fromdomain, replaces); if (PJSIP_URI_SCHEME_IS_SIP(session->request_uri))
snprintf(referto, sizeof(referto), "<sip:%s@%s%s>", target, session->endpoint->fromdomain, replaces);
else if (PJSIP_URI_SCHEME_IS_SIPS(session->request_uri))
snprintf(referto, sizeof(referto), "<sips:%s@%s%s>", target, session->endpoint->fromdomain, replaces);
else if (PJSIP_URI_SCHEME_IS_TEL(session->request_uri))
snprintf(referto, sizeof(referto), "<tel:%s@%s%s>", target, session->endpoint->fromdomain, replaces);
else {
ast_log(LOG_ERROR, "Unsupported URI for Refer-To header. Refer will not be sent!\n");
goto failure;
}
ast_debug(1, "Refer-To: %s\n", referto); ast_debug(1, "Refer-To: %s\n", referto);
if (pjsip_xfer_initiate(sub, pj_cstr(&tmp, referto), &packet) != PJ_SUCCESS) { if (pjsip_xfer_initiate(sub, pj_cstr(&tmp, referto), &packet) != PJ_SUCCESS) {
...@@ -2203,7 +2212,16 @@ static void transfer_refer(struct ast_sip_session *session, const char *target) ...@@ -2203,7 +2212,16 @@ static void transfer_refer(struct ast_sip_session *session, const char *target)
if (!ast_strlen_zero(ref_by_val)) { if (!ast_strlen_zero(ref_by_val)) {
ast_sip_add_header(packet, "Referred-By", ref_by_val); ast_sip_add_header(packet, "Referred-By", ref_by_val);
} else { } else {
snprintf(local_info, sizeof(local_info), "%s@%s", session->endpoint->contact_user, session->endpoint->fromdomain); if (PJSIP_URI_SCHEME_IS_SIP(session->request_uri))
snprintf(local_info, sizeof(local_info), "<sip:%s@%s>", session->endpoint->contact_user, session->endpoint->fromdomain);
else if (PJSIP_URI_SCHEME_IS_SIPS(session->request_uri))
snprintf(local_info, sizeof(local_info), "<sips:%s@%s>", session->endpoint->contact_user, session->endpoint->fromdomain);
else if (PJSIP_URI_SCHEME_IS_TEL(session->request_uri))
snprintf(local_info, sizeof(local_info), "<tel:%s@%s>", session->endpoint->contact_user, session->endpoint->fromdomain);
else {
ast_log(LOG_ERROR, "Unsupported URI for Referred-By header. Refer will not be sent!\n");
goto failure;
}
ast_sip_add_header(packet, "Referred-By", local_info); ast_sip_add_header(packet, "Referred-By", local_info);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment