提交 16e455af authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Transport: Set dtlsState to 'closed' instead of 'failed' upon receipt of a DTLS…

Transport: Set dtlsState to 'closed' instead of 'failed' upon receipt of a DTLS Close Alert (related to https://github.com/openpeer/ortc/issues/327)
上级 a5caa31f
......@@ -61,15 +61,18 @@ namespace RTC
virtual void onDTLSConnecting(DTLSTransport* dtlsTransport) = 0;
// DTLS has completed negotiation of a secure connection (including DTLS-SRTP
// and remote fingerprint verification). Outgoing media can now flow through.
// NOTE: TODO
virtual void onDTLSConnected(DTLSTransport* dtlsTransport, RTC::SRTPSession::SRTPProfile srtp_profile, MS_BYTE* srtp_local_key, size_t srtp_local_key_len, MS_BYTE* srtp_remote_key, size_t srtp_remote_key_len) = 0;
// The DTLS connection has been closed intentionally via Close().
// NOTE: The caller MUST NOT call any method during this callback.
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) = 0;
virtual void onDTLSConnected(DTLSTransport* dtlsTransport, RTC::SRTPSession::SRTPProfile srtp_profile, MS_BYTE* srtp_local_key, size_t srtp_local_key_len, MS_BYTE* srtp_remote_key, size_t srtp_remote_key_len) = 0;
// The DTLS connection has been closed due to receipt of a close_notify alert.
// NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSDisconnected(DTLSTransport* dtlsTransport) = 0;
// The DTLS connection has been closed as the result of an error (such as a
// DTLS alert or a failure to validate the remote fingerprint).
// NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSFailed(DTLSTransport* dtlsTransport) = 0;
// The DTLS connection has been closed intentionally via Close().
// NOTE: The caller MUST NOT call any method during this callback.
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) = 0;
// Need to send DTLS data to the peer.
// NOTE: The caller MUST NOT call Close() during this callback.
virtual void onOutgoingDTLSData(DTLSTransport* dtlsTransport, const MS_BYTE* data, size_t len) = 0;
......
......@@ -104,8 +104,9 @@ namespace RTC
public:
virtual void onDTLSConnecting(DTLSTransport* dtlsTransport) override;
virtual void onDTLSConnected(DTLSTransport* dtlsTransport, RTC::SRTPSession::SRTPProfile srtp_profile, MS_BYTE* srtp_local_key, size_t srtp_local_key_len, MS_BYTE* srtp_remote_key, size_t srtp_remote_key_len) override;
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) override;
virtual void onDTLSDisconnected(DTLSTransport* dtlsTransport) override;
virtual void onDTLSFailed(DTLSTransport* dtlsTransport) override;
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) override;
virtual void onOutgoingDTLSData(RTC::DTLSTransport* dtlsTransport, const MS_BYTE* data, size_t len) override;
virtual void onDTLSApplicationData(RTC::DTLSTransport* dtlsTransport, const MS_BYTE* data, size_t len) override;
......
......@@ -826,7 +826,7 @@ namespace RTC
Reset();
// Notify to the listener.
this->listener->onDTLSFailed(this);
this->listener->onDTLSDisconnected(this);
}
else
{
......
......@@ -770,6 +770,8 @@ namespace RTC
MS_DEBUG("DTLS connecting");
this->dtlsState = DtlsTransportState::CONNECTING;
// TODO: notify 'connecting'.
}
void Transport::onDTLSConnected(RTC::DTLSTransport* dtlsTransport, RTC::SRTPSession::SRTPProfile srtp_profile, MS_BYTE* srtp_local_key, size_t srtp_local_key_len, MS_BYTE* srtp_remote_key, size_t srtp_remote_key_len)
......@@ -783,18 +785,22 @@ namespace RTC
// TODO
// SetLocalSRTPKey(srtp_profile, srtp_local_key, srtp_local_key_len);
// SetRemoteSRTPKey(srtp_profile, srtp_remote_key, srtp_remote_key_len);
// TODO: notify 'connected'.
}
void Transport::onDTLSClosed(RTC::DTLSTransport* dtlsTransport)
void Transport::onDTLSDisconnected(RTC::DTLSTransport* dtlsTransport)
{
MS_TRACE();
MS_DEBUG("DTLS closed");
MS_DEBUG("DTLS remotely disconnected");
this->dtlsState = DtlsTransportState::CLOSED;
// NOTE: This is just called when calling Close() so don't call
// Terminate() here (not needed).
// Call Terminate() so all the servers are closed.
Terminate();
// TODO: notify 'closed' if not already 'closed'.
}
void Transport::onDTLSFailed(RTC::DTLSTransport* dtlsTransport)
......@@ -807,6 +813,22 @@ namespace RTC
// Call Terminate() so all the servers are closed.
Terminate();
// TODO: notify 'failed'.
}
void Transport::onDTLSClosed(RTC::DTLSTransport* dtlsTransport)
{
MS_TRACE();
MS_DEBUG("DTLS closed");
this->dtlsState = DtlsTransportState::CLOSED;
// NOTE: This is just called when calling Close() so don't call
// Terminate() here (not needed).
// TODO: notify 'closed' if not already 'closed'.
}
void Transport::onOutgoingDTLSData(RTC::DTLSTransport* dtlsTransport, const MS_BYTE* data, size_t len)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论