Constify transport stats

BUG=None

Change-Id: I441a46dea97d9a9022b96aaadef1d7348c6f90ee
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/364124
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43148}
This commit is contained in:
Philipp Hancke 2024-09-30 11:58:25 -07:00 committed by WebRTC LUCI CQ
parent 4b53e9af61
commit 4f732f4847
12 changed files with 24 additions and 39 deletions

View File

@ -225,7 +225,7 @@ bool DtlsTransport::GetDtlsRole(rtc::SSLRole* role) const {
return true; return true;
} }
bool DtlsTransport::GetSslCipherSuite(int* cipher) { bool DtlsTransport::GetSslCipherSuite(int* cipher) const {
if (dtls_state() != webrtc::DtlsTransportState::kConnected) { if (dtls_state() != webrtc::DtlsTransportState::kConnected) {
return false; return false;
} }
@ -415,7 +415,7 @@ bool DtlsTransport::SetupDtls() {
return true; return true;
} }
bool DtlsTransport::GetSrtpCryptoSuite(int* cipher) { bool DtlsTransport::GetSrtpCryptoSuite(int* cipher) const {
if (dtls_state() != webrtc::DtlsTransportState::kConnected) { if (dtls_state() != webrtc::DtlsTransportState::kConnected) {
return false; return false;
} }

View File

@ -156,7 +156,7 @@ class DtlsTransport : public DtlsTransportInternal {
// Find out which TLS version was negotiated // Find out which TLS version was negotiated
bool GetSslVersionBytes(int* version) const override; bool GetSslVersionBytes(int* version) const override;
// Find out which DTLS-SRTP cipher was negotiated // Find out which DTLS-SRTP cipher was negotiated
bool GetSrtpCryptoSuite(int* cipher) override; bool GetSrtpCryptoSuite(int* cipher) const override;
// Find out which signature algorithm was used by the peer. Returns values // Find out which signature algorithm was used by the peer. Returns values
// from // from
@ -168,7 +168,7 @@ class DtlsTransport : public DtlsTransportInternal {
bool SetDtlsRole(rtc::SSLRole role) override; bool SetDtlsRole(rtc::SSLRole role) override;
// Find out which DTLS cipher was negotiated // Find out which DTLS cipher was negotiated
bool GetSslCipherSuite(int* cipher) override; bool GetSslCipherSuite(int* cipher) const override;
std::optional<absl::string_view> GetTlsCipherSuiteName() const override; std::optional<absl::string_view> GetTlsCipherSuiteName() const override;
// Once DTLS has been established, this method retrieves the certificate // Once DTLS has been established, this method retrieves the certificate

View File

@ -65,11 +65,11 @@ class DtlsTransportInternal : public rtc::PacketTransportInternal {
virtual bool GetSslVersionBytes(int* version) const = 0; virtual bool GetSslVersionBytes(int* version) const = 0;
// Finds out which DTLS-SRTP cipher was negotiated. // Finds out which DTLS-SRTP cipher was negotiated.
// TODO(zhihuang): Remove this once all dependencies implement this. // TODO(zhihuang): Remove this once all dependencies implement this.
virtual bool GetSrtpCryptoSuite(int* cipher) = 0; virtual bool GetSrtpCryptoSuite(int* cipher) const = 0;
// Finds out which DTLS cipher was negotiated. // Finds out which DTLS cipher was negotiated.
// TODO(zhihuang): Remove this once all dependencies implement this. // TODO(zhihuang): Remove this once all dependencies implement this.
virtual bool GetSslCipherSuite(int* cipher) = 0; virtual bool GetSslCipherSuite(int* cipher) const = 0;
virtual std::optional<absl::string_view> GetTlsCipherSuiteName() const = 0; virtual std::optional<absl::string_view> GetTlsCipherSuiteName() const = 0;
// Find out which signature algorithm was used by the peer. Returns values // Find out which signature algorithm was used by the peer. Returns values

View File

@ -194,7 +194,7 @@ class FakeDtlsTransport : public DtlsTransportInternal {
*version = 0x0102; *version = 0x0102;
return true; return true;
} }
bool GetSrtpCryptoSuite(int* crypto_suite) override { bool GetSrtpCryptoSuite(int* crypto_suite) const override {
if (!do_dtls_) { if (!do_dtls_) {
return false; return false;
} }
@ -203,7 +203,7 @@ class FakeDtlsTransport : public DtlsTransportInternal {
} }
void SetSrtpCryptoSuite(int crypto_suite) { crypto_suite_ = crypto_suite; } void SetSrtpCryptoSuite(int crypto_suite) { crypto_suite_ = crypto_suite; }
bool GetSslCipherSuite(int* cipher_suite) override { bool GetSslCipherSuite(int* cipher_suite) const override {
if (ssl_cipher_suite_) { if (ssl_cipher_suite_) {
*cipher_suite = *ssl_cipher_suite_; *cipher_suite = *ssl_cipher_suite_;
return true; return true;

View File

@ -317,7 +317,7 @@ std::optional<rtc::SSLRole> JsepTransport::GetDtlsRole() const {
return std::optional<rtc::SSLRole>(dtls_role); return std::optional<rtc::SSLRole>(dtls_role);
} }
bool JsepTransport::GetStats(TransportStats* stats) { bool JsepTransport::GetStats(TransportStats* stats) const {
TRACE_EVENT0("webrtc", "JsepTransport::GetStats"); TRACE_EVENT0("webrtc", "JsepTransport::GetStats");
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
stats->transport_name = mid(); stats->transport_name = mid();
@ -634,7 +634,7 @@ webrtc::RTCError JsepTransport::NegotiateDtlsRole(
bool JsepTransport::GetTransportStats(DtlsTransportInternal* dtls_transport, bool JsepTransport::GetTransportStats(DtlsTransportInternal* dtls_transport,
int component, int component,
TransportStats* stats) { TransportStats* stats) const {
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(dtls_transport); RTC_DCHECK(dtls_transport);
TransportChannelStats substats; TransportChannelStats substats;

View File

@ -147,8 +147,7 @@ class JsepTransport {
// negotiated yet. // negotiated yet.
std::optional<rtc::SSLRole> GetDtlsRole() const; std::optional<rtc::SSLRole> GetDtlsRole() const;
// TODO(deadbeef): Make this const. See comment in transportcontroller.h. bool GetStats(TransportStats* stats) const;
bool GetStats(TransportStats* stats);
const JsepTransportDescription* local_description() const { const JsepTransportDescription* local_description() const {
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
@ -285,7 +284,7 @@ class JsepTransport {
bool GetTransportStats(DtlsTransportInternal* dtls_transport, bool GetTransportStats(DtlsTransportInternal* dtls_transport,
int component, int component,
TransportStats* stats); TransportStats* stats) const;
// Owning thread, for safety checks // Owning thread, for safety checks
const rtc::Thread* const network_thread_; const rtc::Thread* const network_thread_;

View File

@ -443,10 +443,11 @@ RTCError JsepTransportController::RemoveRemoteCandidates(
} }
bool JsepTransportController::GetStats(const std::string& transport_name, bool JsepTransportController::GetStats(const std::string& transport_name,
cricket::TransportStats* stats) { cricket::TransportStats* stats) const {
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
cricket::JsepTransport* transport = GetJsepTransportByName(transport_name); const cricket::JsepTransport* transport =
GetJsepTransportByName(transport_name);
if (!transport) { if (!transport) {
return false; return false;
} }

View File

@ -247,10 +247,7 @@ class JsepTransportController : public PayloadTypeSuggester,
PayloadType payload_type, PayloadType payload_type,
const cricket::Codec& codec) override; const cricket::Codec& codec) override;
// TODO(deadbeef): GetStats isn't const because all the way down to bool GetStats(const std::string& mid, cricket::TransportStats* stats) const;
// OpenSSLStreamAdapter, GetSslCipherSuite and GetDtlsSrtpCryptoSuite are not
// const. Fix this.
bool GetStats(const std::string& mid, cricket::TransportStats* stats);
bool initial_offerer() const { return initial_offerer_ && *initial_offerer_; } bool initial_offerer() const { return initial_offerer_ && *initial_offerer_; }

View File

@ -330,7 +330,7 @@ std::optional<absl::string_view> OpenSSLStreamAdapter::GetTlsCipherSuiteName()
return SSL_CIPHER_standard_name(current_cipher); return SSL_CIPHER_standard_name(current_cipher);
} }
bool OpenSSLStreamAdapter::GetSslCipherSuite(int* cipher_suite) { bool OpenSSLStreamAdapter::GetSslCipherSuite(int* cipher_suite) const {
if (state_ != SSL_CONNECTED) { if (state_ != SSL_CONNECTED) {
return false; return false;
} }
@ -437,7 +437,7 @@ bool OpenSSLStreamAdapter::SetDtlsSrtpCryptoSuites(
return true; return true;
} }
bool OpenSSLStreamAdapter::GetDtlsSrtpCryptoSuite(int* crypto_suite) { bool OpenSSLStreamAdapter::GetDtlsSrtpCryptoSuite(int* crypto_suite) const {
RTC_DCHECK(state_ == SSL_CONNECTED); RTC_DCHECK(state_ == SSL_CONNECTED);
if (state_ != SSL_CONNECTED) { if (state_ != SSL_CONNECTED) {
return false; return false;

View File

@ -107,7 +107,7 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter,
std::optional<absl::string_view> GetTlsCipherSuiteName() const override; std::optional<absl::string_view> GetTlsCipherSuiteName() const override;
bool GetSslCipherSuite(int* cipher) override; bool GetSslCipherSuite(int* cipher) const override;
[[deprecated("Use GetSslVersionBytes")]] SSLProtocolVersion GetSslVersion() [[deprecated("Use GetSslVersionBytes")]] SSLProtocolVersion GetSslVersion()
const override; const override;
bool GetSslVersionBytes(int* version) const override; bool GetSslVersionBytes(int* version) const override;
@ -123,7 +123,7 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter,
// DTLS-SRTP interface // DTLS-SRTP interface
bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites) override; bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites) override;
bool GetDtlsSrtpCryptoSuite(int* crypto_suite) override; bool GetDtlsSrtpCryptoSuite(int* crypto_suite) const override;
bool IsTlsConnected() override; bool IsTlsConnected() override;

View File

@ -87,10 +87,6 @@ std::unique_ptr<SSLStreamAdapter> SSLStreamAdapter::Create(
std::move(handshake_error)); std::move(handshake_error));
} }
bool SSLStreamAdapter::GetSslCipherSuite(int* cipher_suite) {
return false;
}
bool SSLStreamAdapter::ExportKeyingMaterial(absl::string_view label, bool SSLStreamAdapter::ExportKeyingMaterial(absl::string_view label,
const uint8_t* context, const uint8_t* context,
size_t context_len, size_t context_len,
@ -100,15 +96,6 @@ bool SSLStreamAdapter::ExportKeyingMaterial(absl::string_view label,
return false; // Default is unsupported return false; // Default is unsupported
} }
bool SSLStreamAdapter::SetDtlsSrtpCryptoSuites(
const std::vector<int>& crypto_suites) {
return false;
}
bool SSLStreamAdapter::GetDtlsSrtpCryptoSuite(int* crypto_suite) {
return false;
}
bool SSLStreamAdapter::IsBoringSsl() { bool SSLStreamAdapter::IsBoringSsl() {
return OpenSSLStreamAdapter::IsBoringSsl(); return OpenSSLStreamAdapter::IsBoringSsl();
} }

View File

@ -184,7 +184,7 @@ class SSLStreamAdapter : public StreamInterface {
// Retrieves the IANA registration id of the cipher suite used for the // Retrieves the IANA registration id of the cipher suite used for the
// connection (e.g. 0x2F for "TLS_RSA_WITH_AES_128_CBC_SHA"). // connection (e.g. 0x2F for "TLS_RSA_WITH_AES_128_CBC_SHA").
virtual bool GetSslCipherSuite(int* cipher_suite); virtual bool GetSslCipherSuite(int* cipher_suite) const = 0;
// Returns the name of the cipher suite used for the DTLS transport, // Returns the name of the cipher suite used for the DTLS transport,
// as defined in the "Description" column of the IANA cipher suite registry. // as defined in the "Description" column of the IANA cipher suite registry.
virtual std::optional<absl::string_view> GetTlsCipherSuiteName() const = 0; virtual std::optional<absl::string_view> GetTlsCipherSuiteName() const = 0;
@ -220,8 +220,9 @@ class SSLStreamAdapter : public StreamInterface {
virtual uint16_t GetPeerSignatureAlgorithm() const = 0; virtual uint16_t GetPeerSignatureAlgorithm() const = 0;
// DTLS-SRTP interface // DTLS-SRTP interface
virtual bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites); virtual bool SetDtlsSrtpCryptoSuites(
virtual bool GetDtlsSrtpCryptoSuite(int* crypto_suite); const std::vector<int>& crypto_suites) = 0;
virtual bool GetDtlsSrtpCryptoSuite(int* crypto_suite) const = 0;
// Returns true if a TLS connection has been established. // Returns true if a TLS connection has been established.
// The only difference between this and "GetState() == SE_OPEN" is that if // The only difference between this and "GetState() == SE_OPEN" is that if