Commit b3b3a6ce authored by Adrien Béraud's avatar Adrien Béraud

sip: set transport secure state

When receiving an incoming SIPS or Ring call, enforces the
secure state of the media as it should be per the SIP
standard.

Also prevents to accidentally configure an insecure
transport on a secure call.

Change-Id: I28836c76f79218a026b07d7c182adbaaf50aedbb
Tuleap: #901
parent 6e6b106b
......@@ -175,6 +175,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl)
auto& manager = Manager::instance();
auto call = manager.callFactory.newCall<SIPCall, SIPAccount>(*this, manager.getNewCallID(), Call::CallType::OUTGOING);
call->setSecure(isTlsEnabled());
if (isIP2IP()) {
bool ipv6 = false;
......@@ -204,9 +205,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl)
auto toUri = getToUri(to);
call->initIceTransport(true);
call->setIPToIP(isIP2IP());
call->setSecure(isTlsEnabled());
call->setPeerNumber(toUri);
call->initRecFilename(to);
......
......@@ -179,12 +179,18 @@ void SIPCall::setContactHeader(pj_str_t *contact)
void
SIPCall::setTransport(std::shared_ptr<SipTransport> t)
{
if (isSecure() and t and not t->isSecure()) {
RING_ERR("Can't set unsecure transport to secure call.");
return;
}
const auto list_id = reinterpret_cast<uintptr_t>(this);
if (transport_)
transport_->removeStateListener(list_id);
transport_ = t;
if (transport_) {
setSecure(transport_->isSecure());
std::weak_ptr<SIPCall> wthis_ = std::static_pointer_cast<SIPCall>(shared_from_this());
// listen for transport destruction
......
Markdown is supported
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