Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel.cc

Issue 1458023002: Reland Convert internal representation of Srtp cryptos from string to int (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (!dtls_->SetPeerCertificateDigest( 260 if (!dtls_->SetPeerCertificateDigest(
261 remote_fingerprint_algorithm_, 261 remote_fingerprint_algorithm_,
262 reinterpret_cast<unsigned char*>(remote_fingerprint_value_.data()), 262 reinterpret_cast<unsigned char*>(remote_fingerprint_value_.data()),
263 remote_fingerprint_value_.size())) { 263 remote_fingerprint_value_.size())) {
264 LOG_J(LS_ERROR, this) << "Couldn't set DTLS certificate digest."; 264 LOG_J(LS_ERROR, this) << "Couldn't set DTLS certificate digest.";
265 return false; 265 return false;
266 } 266 }
267 267
268 // Set up DTLS-SRTP, if it's been enabled. 268 // Set up DTLS-SRTP, if it's been enabled.
269 if (!srtp_ciphers_.empty()) { 269 if (!srtp_ciphers_.empty()) {
270 if (!dtls_->SetDtlsSrtpCiphers(srtp_ciphers_)) { 270 if (!dtls_->SetDtlsSrtpCryptoSuites(srtp_ciphers_)) {
271 LOG_J(LS_ERROR, this) << "Couldn't set DTLS-SRTP ciphers."; 271 LOG_J(LS_ERROR, this) << "Couldn't set DTLS-SRTP ciphers.";
272 return false; 272 return false;
273 } 273 }
274 } else { 274 } else {
275 LOG_J(LS_INFO, this) << "Not using DTLS-SRTP."; 275 LOG_J(LS_INFO, this) << "Not using DTLS-SRTP.";
276 } 276 }
277 277
278 LOG_J(LS_INFO, this) << "DTLS setup complete."; 278 LOG_J(LS_INFO, this) << "DTLS setup complete.";
279 return true; 279 return true;
280 } 280 }
281 281
282 bool DtlsTransportChannelWrapper::SetSrtpCiphers( 282 bool DtlsTransportChannelWrapper::SetSrtpCryptoSuites(
283 const std::vector<std::string>& ciphers) { 283 const std::vector<int>& ciphers) {
284 if (srtp_ciphers_ == ciphers) { 284 if (srtp_ciphers_ == ciphers)
285 return true; 285 return true;
286 }
287 286
288 if (dtls_state() == DTLS_TRANSPORT_CONNECTING) { 287 if (dtls_state() == DTLS_TRANSPORT_CONNECTING) {
289 LOG(LS_WARNING) << "Ignoring new SRTP ciphers while DTLS is negotiating"; 288 LOG(LS_WARNING) << "Ignoring new SRTP ciphers while DTLS is negotiating";
290 return true; 289 return true;
291 } 290 }
292 291
293 if (dtls_state() == DTLS_TRANSPORT_CONNECTED) { 292 if (dtls_state() == DTLS_TRANSPORT_CONNECTED) {
294 // We don't support DTLS renegotiation currently. If new set of srtp ciphers 293 // We don't support DTLS renegotiation currently. If new set of srtp ciphers
295 // are different than what's being used currently, we will not use it. 294 // are different than what's being used currently, we will not use it.
296 // So for now, let's be happy (or sad) with a warning message. 295 // So for now, let's be happy (or sad) with a warning message.
297 std::string current_srtp_cipher; 296 int current_srtp_cipher;
298 if (!dtls_->GetDtlsSrtpCipher(&current_srtp_cipher)) { 297 if (!dtls_->GetDtlsSrtpCryptoSuite(&current_srtp_cipher)) {
299 LOG(LS_ERROR) << "Failed to get the current SRTP cipher for DTLS channel"; 298 LOG(LS_ERROR) << "Failed to get the current SRTP cipher for DTLS channel";
300 return false; 299 return false;
301 } 300 }
302 const std::vector<std::string>::const_iterator iter = 301 const std::vector<int>::const_iterator iter =
303 std::find(ciphers.begin(), ciphers.end(), current_srtp_cipher); 302 std::find(ciphers.begin(), ciphers.end(), current_srtp_cipher);
304 if (iter == ciphers.end()) { 303 if (iter == ciphers.end()) {
305 std::string requested_str; 304 std::string requested_str;
306 for (size_t i = 0; i < ciphers.size(); ++i) { 305 for (size_t i = 0; i < ciphers.size(); ++i) {
307 requested_str.append(" "); 306 requested_str.append(" ");
308 requested_str.append(ciphers[i]); 307 requested_str.append(rtc::SrtpCryptoSuiteToName(ciphers[i]));
309 requested_str.append(" "); 308 requested_str.append(" ");
310 } 309 }
311 LOG(LS_WARNING) << "Ignoring new set of SRTP ciphers, as DTLS " 310 LOG(LS_WARNING) << "Ignoring new set of SRTP ciphers, as DTLS "
312 << "renegotiation is not supported currently " 311 << "renegotiation is not supported currently "
313 << "current cipher = " << current_srtp_cipher << " and " 312 << "current cipher = " << current_srtp_cipher << " and "
314 << "requested = " << "[" << requested_str << "]"; 313 << "requested = " << "[" << requested_str << "]";
315 } 314 }
316 return true; 315 return true;
317 } 316 }
318 317
319 if (!VERIFY(dtls_state() == DTLS_TRANSPORT_NEW)) { 318 if (!VERIFY(dtls_state() == DTLS_TRANSPORT_NEW)) {
320 return false; 319 return false;
321 } 320 }
322 321
323 srtp_ciphers_ = ciphers; 322 srtp_ciphers_ = ciphers;
324 return true; 323 return true;
325 } 324 }
326 325
327 bool DtlsTransportChannelWrapper::GetSrtpCryptoSuite(std::string* cipher) { 326 bool DtlsTransportChannelWrapper::GetSrtpCryptoSuite(int* cipher) {
328 if (dtls_state() != DTLS_TRANSPORT_CONNECTED) { 327 if (dtls_state() != DTLS_TRANSPORT_CONNECTED) {
329 return false; 328 return false;
330 } 329 }
331 330
332 return dtls_->GetDtlsSrtpCipher(cipher); 331 return dtls_->GetDtlsSrtpCryptoSuite(cipher);
333 } 332 }
334 333
335 334
336 // Called from upper layers to send a media packet. 335 // Called from upper layers to send a media packet.
337 int DtlsTransportChannelWrapper::SendPacket( 336 int DtlsTransportChannelWrapper::SendPacket(
338 const char* data, size_t size, 337 const char* data, size_t size,
339 const rtc::PacketOptions& options, int flags) { 338 const rtc::PacketOptions& options, int flags) {
340 if (!dtls_active_) { 339 if (!dtls_active_) {
341 // Not doing DTLS. 340 // Not doing DTLS.
342 return channel_->SendPacket(data, size, options); 341 return channel_->SendPacket(data, size, options);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 SignalRouteChange(this, candidate); 610 SignalRouteChange(this, candidate);
612 } 611 }
613 612
614 void DtlsTransportChannelWrapper::OnConnectionRemoved( 613 void DtlsTransportChannelWrapper::OnConnectionRemoved(
615 TransportChannelImpl* channel) { 614 TransportChannelImpl* channel) {
616 ASSERT(channel == channel_); 615 ASSERT(channel == channel_);
617 SignalConnectionRemoved(this); 616 SignalConnectionRemoved(this);
618 } 617 }
619 618
620 } // namespace cricket 619 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel.h ('k') | webrtc/p2p/base/dtlstransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698