Commit d4ddf067 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #28358: sip: ensure correct Contact Header is present for RINGING and OK

parent c1baecf0
......@@ -232,6 +232,17 @@ void updateSDPFromSTUN(SIPCall &call, SIPAccount &account, const SipTransport &t
}
}
void
addContactHeader(const std::string &contactStr, pjsip_tx_data *tdata)
{
pj_str_t pjContact = pj_str((char*) contactStr.c_str());
pjsip_contact_hdr *contact = pjsip_contact_hdr_create(tdata->pool);
contact->uri = pjsip_parse_uri(tdata->pool, pjContact.ptr,
pjContact.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) contact);
}
pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
{
......@@ -466,6 +477,10 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
return PJ_FALSE;
}
// contactStr must stay in scope as long as tdata
const std::string contactStr(account->getContactHeader());
addContactHeader(contactStr, tdata);
if (pjsip_inv_send_msg(call->inv, tdata) != PJ_SUCCESS) {
ERROR("Could not send msg for invite");
delete call;
......@@ -1034,17 +1049,6 @@ void stopRtpIfCurrent(const std::string &id, SIPCall &call)
#endif
}
}
void addContactHeader(const SIPAccount &account, pjsip_tx_data *tdata)
{
const std::string contactStr(account.getContactHeader());
pj_str_t pjContact = pj_str((char*) contactStr.c_str());
pjsip_contact_hdr *contact = pjsip_contact_hdr_create(tdata->pool);
contact->uri = pjsip_parse_uri(tdata->pool, pjContact.ptr,
pjContact.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) contact);
}
}
void
......@@ -1088,7 +1092,9 @@ SIPVoIPLink::hangup(const std::string& id, int reason)
if (pjsip_inv_end_session(inv, status, NULL, &tdata) != PJ_SUCCESS || !tdata)
return;
addContactHeader(*account, tdata);
// contactStr must stay in scope as long as tdata
const std::string contactStr(account->getContactHeader());
addContactHeader(contactStr, tdata);
if (pjsip_inv_send_msg(inv, tdata) != PJ_SUCCESS)
return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment