| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 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 |
| 11 #include "webrtc/pc/srtpfilter.h" | 11 #include "webrtc/pc/srtpfilter.h" |
| 12 | 12 |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 | 14 |
| 15 #include <algorithm> | 15 #include <algorithm> |
| 16 | 16 |
| 17 #include "webrtc/base/base64.h" | 17 #include "webrtc/base/base64.h" |
| 18 #include "webrtc/base/buffer.h" | 18 #include "webrtc/base/buffer.h" |
| 19 #include "webrtc/base/byteorder.h" | 19 #include "webrtc/base/byteorder.h" |
| 20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
| 21 #include "webrtc/base/common.h" | 21 #include "webrtc/base/common.h" |
| 22 #include "webrtc/base/logging.h" | 22 #include "webrtc/base/logging.h" |
| 23 #include "webrtc/base/stringencode.h" | 23 #include "webrtc/base/stringencode.h" |
| 24 #include "webrtc/base/timeutils.h" | 24 #include "webrtc/base/timeutils.h" |
| 25 #include "webrtc/media/base/rtputils.h" | 25 #include "webrtc/media/base/rtputils.h" |
| 26 #include "webrtc/pc/externalhmac.h" |
| 26 | 27 |
| 27 // Enable this line to turn on SRTP debugging | 28 // Enable this line to turn on SRTP debugging |
| 28 // #define SRTP_DEBUG | 29 // #define SRTP_DEBUG |
| 29 | 30 |
| 30 #ifdef HAVE_SRTP | 31 #ifdef HAVE_SRTP |
| 31 extern "C" { | 32 extern "C" { |
| 32 #ifdef SRTP_RELATIVE_PATH | 33 #ifdef SRTP_RELATIVE_PATH |
| 33 #include "srtp.h" // NOLINT | 34 #include "srtp.h" // NOLINT |
| 34 #include "srtp_priv.h" // NOLINT | 35 #include "srtp_priv.h" // NOLINT |
| 35 #else | 36 #else |
| 36 #include "third_party/libsrtp/srtp/include/srtp.h" | 37 #include "third_party/libsrtp/include/srtp.h" |
| 37 #include "third_party/libsrtp/srtp/include/srtp_priv.h" | 38 #include "third_party/libsrtp/include/srtp_priv.h" |
| 38 #endif // SRTP_RELATIVE_PATH | 39 #endif // SRTP_RELATIVE_PATH |
| 39 } | 40 } |
| 40 #ifdef ENABLE_EXTERNAL_AUTH | 41 |
| 41 #include "webrtc/pc/externalhmac.h" | |
| 42 #endif // ENABLE_EXTERNAL_AUTH | |
| 43 #if !defined(NDEBUG) | 42 #if !defined(NDEBUG) |
| 44 extern "C" debug_module_t mod_srtp; | 43 extern "C" srtp_debug_module_t mod_srtp; |
| 45 extern "C" debug_module_t mod_auth; | 44 extern "C" srtp_debug_module_t mod_auth; |
| 46 extern "C" debug_module_t mod_cipher; | 45 extern "C" srtp_debug_module_t mod_cipher; |
| 47 extern "C" debug_module_t mod_stat; | 46 extern "C" srtp_debug_module_t mod_stat; |
| 48 extern "C" debug_module_t mod_alloc; | 47 extern "C" srtp_debug_module_t mod_alloc; |
| 49 extern "C" debug_module_t mod_aes_icm; | 48 extern "C" srtp_debug_module_t mod_aes_icm; |
| 50 extern "C" debug_module_t mod_aes_hmac; | 49 extern "C" srtp_debug_module_t mod_aes_hmac; |
| 51 #endif | 50 #endif |
| 52 #endif // HAVE_SRTP | 51 #endif // HAVE_SRTP |
| 53 | 52 |
| 54 namespace cricket { | 53 namespace cricket { |
| 55 | 54 |
| 56 #ifndef HAVE_SRTP | 55 #ifndef HAVE_SRTP |
| 57 | 56 |
| 58 // This helper function is used on systems that don't (yet) have SRTP, | 57 // This helper function is used on systems that don't (yet) have SRTP, |
| 59 // to log that the functions that require it won't do anything. | 58 // to log that the functions that require it won't do anything. |
| 60 namespace { | 59 namespace { |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 529 } |
| 531 | 530 |
| 532 *out_len = in_len; | 531 *out_len = in_len; |
| 533 int err = srtp_protect(session_, p, out_len); | 532 int err = srtp_protect(session_, p, out_len); |
| 534 uint32_t ssrc; | 533 uint32_t ssrc; |
| 535 if (GetRtpSsrc(p, in_len, &ssrc)) { | 534 if (GetRtpSsrc(p, in_len, &ssrc)) { |
| 536 srtp_stat_->AddProtectRtpResult(ssrc, err); | 535 srtp_stat_->AddProtectRtpResult(ssrc, err); |
| 537 } | 536 } |
| 538 int seq_num; | 537 int seq_num; |
| 539 GetRtpSeqNum(p, in_len, &seq_num); | 538 GetRtpSeqNum(p, in_len, &seq_num); |
| 540 if (err != err_status_ok) { | 539 if (err != srtp_err_status_ok) { |
| 541 LOG(LS_WARNING) << "Failed to protect SRTP packet, seqnum=" | 540 LOG(LS_WARNING) << "Failed to protect SRTP packet, seqnum=" |
| 542 << seq_num << ", err=" << err << ", last seqnum=" | 541 << seq_num << ", err=" << err << ", last seqnum=" |
| 543 << last_send_seq_num_; | 542 << last_send_seq_num_; |
| 544 return false; | 543 return false; |
| 545 } | 544 } |
| 546 last_send_seq_num_ = seq_num; | 545 last_send_seq_num_ = seq_num; |
| 547 return true; | 546 return true; |
| 548 } | 547 } |
| 549 | 548 |
| 550 bool SrtpSession::ProtectRtp(void* p, | 549 bool SrtpSession::ProtectRtp(void* p, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 568 int need_len = in_len + sizeof(uint32_t) + rtcp_auth_tag_len_; // NOLINT | 567 int need_len = in_len + sizeof(uint32_t) + rtcp_auth_tag_len_; // NOLINT |
| 569 if (max_len < need_len) { | 568 if (max_len < need_len) { |
| 570 LOG(LS_WARNING) << "Failed to protect SRTCP packet: The buffer length " | 569 LOG(LS_WARNING) << "Failed to protect SRTCP packet: The buffer length " |
| 571 << max_len << " is less than the needed " << need_len; | 570 << max_len << " is less than the needed " << need_len; |
| 572 return false; | 571 return false; |
| 573 } | 572 } |
| 574 | 573 |
| 575 *out_len = in_len; | 574 *out_len = in_len; |
| 576 int err = srtp_protect_rtcp(session_, p, out_len); | 575 int err = srtp_protect_rtcp(session_, p, out_len); |
| 577 srtp_stat_->AddProtectRtcpResult(err); | 576 srtp_stat_->AddProtectRtcpResult(err); |
| 578 if (err != err_status_ok) { | 577 if (err != srtp_err_status_ok) { |
| 579 LOG(LS_WARNING) << "Failed to protect SRTCP packet, err=" << err; | 578 LOG(LS_WARNING) << "Failed to protect SRTCP packet, err=" << err; |
| 580 return false; | 579 return false; |
| 581 } | 580 } |
| 582 return true; | 581 return true; |
| 583 } | 582 } |
| 584 | 583 |
| 585 bool SrtpSession::UnprotectRtp(void* p, int in_len, int* out_len) { | 584 bool SrtpSession::UnprotectRtp(void* p, int in_len, int* out_len) { |
| 586 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 585 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 587 if (!session_) { | 586 if (!session_) { |
| 588 LOG(LS_WARNING) << "Failed to unprotect SRTP packet: no SRTP Session"; | 587 LOG(LS_WARNING) << "Failed to unprotect SRTP packet: no SRTP Session"; |
| 589 return false; | 588 return false; |
| 590 } | 589 } |
| 591 | 590 |
| 592 *out_len = in_len; | 591 *out_len = in_len; |
| 593 int err = srtp_unprotect(session_, p, out_len); | 592 int err = srtp_unprotect(session_, p, out_len); |
| 594 uint32_t ssrc; | 593 uint32_t ssrc; |
| 595 if (GetRtpSsrc(p, in_len, &ssrc)) { | 594 if (GetRtpSsrc(p, in_len, &ssrc)) { |
| 596 srtp_stat_->AddUnprotectRtpResult(ssrc, err); | 595 srtp_stat_->AddUnprotectRtpResult(ssrc, err); |
| 597 } | 596 } |
| 598 if (err != err_status_ok) { | 597 if (err != srtp_err_status_ok) { |
| 599 LOG(LS_WARNING) << "Failed to unprotect SRTP packet, err=" << err; | 598 LOG(LS_WARNING) << "Failed to unprotect SRTP packet, err=" << err; |
| 600 return false; | 599 return false; |
| 601 } | 600 } |
| 602 return true; | 601 return true; |
| 603 } | 602 } |
| 604 | 603 |
| 605 bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) { | 604 bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) { |
| 606 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 605 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 607 if (!session_) { | 606 if (!session_) { |
| 608 LOG(LS_WARNING) << "Failed to unprotect SRTCP packet: no SRTP Session"; | 607 LOG(LS_WARNING) << "Failed to unprotect SRTCP packet: no SRTP Session"; |
| 609 return false; | 608 return false; |
| 610 } | 609 } |
| 611 | 610 |
| 612 *out_len = in_len; | 611 *out_len = in_len; |
| 613 int err = srtp_unprotect_rtcp(session_, p, out_len); | 612 int err = srtp_unprotect_rtcp(session_, p, out_len); |
| 614 srtp_stat_->AddUnprotectRtcpResult(err); | 613 srtp_stat_->AddUnprotectRtcpResult(err); |
| 615 if (err != err_status_ok) { | 614 if (err != srtp_err_status_ok) { |
| 616 LOG(LS_WARNING) << "Failed to unprotect SRTCP packet, err=" << err; | 615 LOG(LS_WARNING) << "Failed to unprotect SRTCP packet, err=" << err; |
| 617 return false; | 616 return false; |
| 618 } | 617 } |
| 619 return true; | 618 return true; |
| 620 } | 619 } |
| 621 | 620 |
| 622 bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { | 621 bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { |
| 623 #if defined(ENABLE_EXTERNAL_AUTH) | 622 #if defined(ENABLE_EXTERNAL_AUTH) |
| 624 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 623 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 625 ExternalHmacContext* external_hmac = nullptr; | 624 ExternalHmacContext* external_hmac = nullptr; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 650 int64_t* index) { | 649 int64_t* index) { |
| 651 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 650 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 652 srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p); | 651 srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p); |
| 653 srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc); | 652 srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc); |
| 654 if (!stream) { | 653 if (!stream) { |
| 655 return false; | 654 return false; |
| 656 } | 655 } |
| 657 | 656 |
| 658 // Shift packet index, put into network byte order | 657 // Shift packet index, put into network byte order |
| 659 *index = static_cast<int64_t>( | 658 *index = static_cast<int64_t>( |
| 660 rtc::NetworkToHost64(rdbx_get_packet_index(&stream->rtp_rdbx) << 16)); | 659 rtc::NetworkToHost64( |
| 660 srtp_rdbx_get_packet_index(&stream->rtp_rdbx) << 16)); |
| 661 return true; | 661 return true; |
| 662 } | 662 } |
| 663 | 663 |
| 664 void SrtpSession::set_signal_silent_time(int signal_silent_time_in_ms) { | 664 void SrtpSession::set_signal_silent_time(int signal_silent_time_in_ms) { |
| 665 srtp_stat_->set_signal_silent_time(signal_silent_time_in_ms); | 665 srtp_stat_->set_signal_silent_time(signal_silent_time_in_ms); |
| 666 } | 666 } |
| 667 | 667 |
| 668 bool SrtpSession::SetKey(int type, int cs, const uint8_t* key, size_t len) { | 668 bool SrtpSession::SetKey(int type, int cs, const uint8_t* key, size_t len) { |
| 669 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 669 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 670 if (session_) { | 670 if (session_) { |
| 671 LOG(LS_ERROR) << "Failed to create SRTP session: " | 671 LOG(LS_ERROR) << "Failed to create SRTP session: " |
| 672 << "SRTP session already created"; | 672 << "SRTP session already created"; |
| 673 return false; | 673 return false; |
| 674 } | 674 } |
| 675 | 675 |
| 676 if (!Init()) { | 676 if (!Init()) { |
| 677 return false; | 677 return false; |
| 678 } | 678 } |
| 679 | 679 |
| 680 srtp_policy_t policy; | 680 srtp_policy_t policy; |
| 681 memset(&policy, 0, sizeof(policy)); | 681 memset(&policy, 0, sizeof(policy)); |
| 682 if (cs == rtc::SRTP_AES128_CM_SHA1_80) { | 682 if (cs == rtc::SRTP_AES128_CM_SHA1_80) { |
| 683 crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtp); | 683 srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtp); |
| 684 crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp); | 684 srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp); |
| 685 } else if (cs == rtc::SRTP_AES128_CM_SHA1_32) { | 685 } else if (cs == rtc::SRTP_AES128_CM_SHA1_32) { |
| 686 crypto_policy_set_aes_cm_128_hmac_sha1_32(&policy.rtp); // rtp is 32, | 686 // RTP HMAC is shortened to 32 bits, but RTCP remains 80 bits. |
| 687 crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp); // rtcp still 80 | 687 srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(&policy.rtp); |
| 688 srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp); |
| 688 #if !defined(ENABLE_EXTERNAL_AUTH) | 689 #if !defined(ENABLE_EXTERNAL_AUTH) |
| 689 // TODO(jbauch): Re-enable once https://crbug.com/628400 is resolved. | 690 // TODO(jbauch): Re-enable once https://crbug.com/628400 is resolved. |
| 690 } else if (cs == rtc::SRTP_AEAD_AES_128_GCM) { | 691 } else if (cs == rtc::SRTP_AEAD_AES_128_GCM) { |
| 691 crypto_policy_set_aes_gcm_128_16_auth(&policy.rtp); | 692 srtp_crypto_policy_set_aes_gcm_128_16_auth(&policy.rtp); |
| 692 crypto_policy_set_aes_gcm_128_16_auth(&policy.rtcp); | 693 srtp_crypto_policy_set_aes_gcm_128_16_auth(&policy.rtcp); |
| 693 } else if (cs == rtc::SRTP_AEAD_AES_256_GCM) { | 694 } else if (cs == rtc::SRTP_AEAD_AES_256_GCM) { |
| 694 crypto_policy_set_aes_gcm_256_16_auth(&policy.rtp); | 695 srtp_crypto_policy_set_aes_gcm_256_16_auth(&policy.rtp); |
| 695 crypto_policy_set_aes_gcm_256_16_auth(&policy.rtcp); | 696 srtp_crypto_policy_set_aes_gcm_256_16_auth(&policy.rtcp); |
| 696 #endif // ENABLE_EXTERNAL_AUTH | 697 #endif // ENABLE_EXTERNAL_AUTH |
| 697 } else { | 698 } else { |
| 698 LOG(LS_WARNING) << "Failed to create SRTP session: unsupported" | 699 LOG(LS_WARNING) << "Failed to create SRTP session: unsupported" |
| 699 << " cipher_suite " << cs; | 700 << " cipher_suite " << cs; |
| 700 return false; | 701 return false; |
| 701 } | 702 } |
| 702 | 703 |
| 703 int expected_key_len; | 704 int expected_key_len; |
| 704 int expected_salt_len; | 705 int expected_salt_len; |
| 705 if (!rtc::GetSrtpKeyAndSaltLengths(cs, &expected_key_len, | 706 if (!rtc::GetSrtpKeyAndSaltLengths(cs, &expected_key_len, |
| 706 &expected_salt_len)) { | 707 &expected_salt_len)) { |
| 707 // This should never happen. | 708 // This should never happen. |
| 708 LOG(LS_WARNING) << "Failed to create SRTP session: unsupported" | 709 LOG(LS_WARNING) << "Failed to create SRTP session: unsupported" |
| 709 << " cipher_suite without length information" << cs; | 710 << " cipher_suite without length information" << cs; |
| 710 return false; | 711 return false; |
| 711 } | 712 } |
| 712 | 713 |
| 713 if (!key || | 714 if (!key || |
| 714 len != static_cast<size_t>(expected_key_len + expected_salt_len)) { | 715 len != static_cast<size_t>(expected_key_len + expected_salt_len)) { |
| 715 LOG(LS_WARNING) << "Failed to create SRTP session: invalid key"; | 716 LOG(LS_WARNING) << "Failed to create SRTP session: invalid key"; |
| 716 return false; | 717 return false; |
| 717 } | 718 } |
| 718 | 719 |
| 719 policy.ssrc.type = static_cast<ssrc_type_t>(type); | 720 policy.ssrc.type = static_cast<srtp_ssrc_type_t>(type); |
| 720 policy.ssrc.value = 0; | 721 policy.ssrc.value = 0; |
| 721 policy.key = const_cast<uint8_t*>(key); | 722 policy.key = const_cast<uint8_t*>(key); |
| 722 // TODO(astor) parse window size from WSH session-param | 723 // TODO(astor) parse window size from WSH session-param |
| 723 policy.window_size = 1024; | 724 policy.window_size = 1024; |
| 724 policy.allow_repeat_tx = 1; | 725 policy.allow_repeat_tx = 1; |
| 725 // If external authentication option is enabled, supply custom auth module | 726 // If external authentication option is enabled, supply custom auth module |
| 726 // id EXTERNAL_HMAC_SHA1 in the policy structure. | 727 // id EXTERNAL_HMAC_SHA1 in the policy structure. |
| 727 // We want to set this option only for rtp packets. | 728 // We want to set this option only for rtp packets. |
| 728 // By default policy structure is initialized to HMAC_SHA1. | 729 // By default policy structure is initialized to HMAC_SHA1. |
| 729 #if defined(ENABLE_EXTERNAL_AUTH) | 730 #if defined(ENABLE_EXTERNAL_AUTH) |
| 730 // Enable external HMAC authentication only for outgoing streams. | 731 // Enable external HMAC authentication only for outgoing streams. |
| 731 if (type == ssrc_any_outbound) { | 732 if (type == ssrc_any_outbound) { |
| 732 policy.rtp.auth_type = EXTERNAL_HMAC_SHA1; | 733 policy.rtp.auth_type = EXTERNAL_HMAC_SHA1; |
| 733 } | 734 } |
| 734 #endif | 735 #endif |
| 735 policy.next = nullptr; | 736 policy.next = nullptr; |
| 736 | 737 |
| 737 int err = srtp_create(&session_, &policy); | 738 int err = srtp_create(&session_, &policy); |
| 738 if (err != err_status_ok) { | 739 if (err != srtp_err_status_ok) { |
| 739 session_ = nullptr; | 740 session_ = nullptr; |
| 740 LOG(LS_ERROR) << "Failed to create SRTP session, err=" << err; | 741 LOG(LS_ERROR) << "Failed to create SRTP session, err=" << err; |
| 741 return false; | 742 return false; |
| 742 } | 743 } |
| 743 | 744 |
| 744 srtp_set_user_data(session_, this); | 745 srtp_set_user_data(session_, this); |
| 745 rtp_auth_tag_len_ = policy.rtp.auth_tag_len; | 746 rtp_auth_tag_len_ = policy.rtp.auth_tag_len; |
| 746 rtcp_auth_tag_len_ = policy.rtcp.auth_tag_len; | 747 rtcp_auth_tag_len_ = policy.rtcp.auth_tag_len; |
| 747 return true; | 748 return true; |
| 748 } | 749 } |
| 749 | 750 |
| 750 bool SrtpSession::Init() { | 751 bool SrtpSession::Init() { |
| 751 rtc::GlobalLockScope ls(&lock_); | 752 rtc::GlobalLockScope ls(&lock_); |
| 752 | 753 |
| 753 if (!inited_) { | 754 if (!inited_) { |
| 754 int err; | 755 int err; |
| 755 err = srtp_init(); | 756 err = srtp_init(); |
| 756 if (err != err_status_ok) { | 757 if (err != srtp_err_status_ok) { |
| 757 LOG(LS_ERROR) << "Failed to init SRTP, err=" << err; | 758 LOG(LS_ERROR) << "Failed to init SRTP, err=" << err; |
| 758 return false; | 759 return false; |
| 759 } | 760 } |
| 760 | 761 |
| 761 err = srtp_install_event_handler(&SrtpSession::HandleEventThunk); | 762 err = srtp_install_event_handler(&SrtpSession::HandleEventThunk); |
| 762 if (err != err_status_ok) { | 763 if (err != srtp_err_status_ok) { |
| 763 LOG(LS_ERROR) << "Failed to install SRTP event handler, err=" << err; | 764 LOG(LS_ERROR) << "Failed to install SRTP event handler, err=" << err; |
| 764 return false; | 765 return false; |
| 765 } | 766 } |
| 766 #if defined(ENABLE_EXTERNAL_AUTH) | 767 #if defined(ENABLE_EXTERNAL_AUTH) |
| 767 err = external_crypto_init(); | 768 err = external_crypto_init(); |
| 768 if (err != err_status_ok) { | 769 if (err != srtp_err_status_ok) { |
| 769 LOG(LS_ERROR) << "Failed to initialize fake auth, err=" << err; | 770 LOG(LS_ERROR) << "Failed to initialize fake auth, err=" << err; |
| 770 return false; | 771 return false; |
| 771 } | 772 } |
| 772 #endif | 773 #endif |
| 773 inited_ = true; | 774 inited_ = true; |
| 774 } | 775 } |
| 775 | 776 |
| 776 return true; | 777 return true; |
| 777 } | 778 } |
| 778 | 779 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 871 |
| 871 SrtpStat::SrtpStat() | 872 SrtpStat::SrtpStat() |
| 872 : signal_silent_time_(1000) { | 873 : signal_silent_time_(1000) { |
| 873 } | 874 } |
| 874 | 875 |
| 875 void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) { | 876 void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) { |
| 876 FailureKey key; | 877 FailureKey key; |
| 877 key.ssrc = ssrc; | 878 key.ssrc = ssrc; |
| 878 key.mode = SrtpFilter::PROTECT; | 879 key.mode = SrtpFilter::PROTECT; |
| 879 switch (result) { | 880 switch (result) { |
| 880 case err_status_ok: | 881 case srtp_err_status_ok: |
| 881 key.error = SrtpFilter::ERROR_NONE; | 882 key.error = SrtpFilter::ERROR_NONE; |
| 882 break; | 883 break; |
| 883 case err_status_auth_fail: | 884 case srtp_err_status_auth_fail: |
| 884 key.error = SrtpFilter::ERROR_AUTH; | 885 key.error = SrtpFilter::ERROR_AUTH; |
| 885 break; | 886 break; |
| 886 default: | 887 default: |
| 887 key.error = SrtpFilter::ERROR_FAIL; | 888 key.error = SrtpFilter::ERROR_FAIL; |
| 888 } | 889 } |
| 889 HandleSrtpResult(key); | 890 HandleSrtpResult(key); |
| 890 } | 891 } |
| 891 | 892 |
| 892 void SrtpStat::AddUnprotectRtpResult(uint32_t ssrc, int result) { | 893 void SrtpStat::AddUnprotectRtpResult(uint32_t ssrc, int result) { |
| 893 FailureKey key; | 894 FailureKey key; |
| 894 key.ssrc = ssrc; | 895 key.ssrc = ssrc; |
| 895 key.mode = SrtpFilter::UNPROTECT; | 896 key.mode = SrtpFilter::UNPROTECT; |
| 896 switch (result) { | 897 switch (result) { |
| 897 case err_status_ok: | 898 case srtp_err_status_ok: |
| 898 key.error = SrtpFilter::ERROR_NONE; | 899 key.error = SrtpFilter::ERROR_NONE; |
| 899 break; | 900 break; |
| 900 case err_status_auth_fail: | 901 case srtp_err_status_auth_fail: |
| 901 key.error = SrtpFilter::ERROR_AUTH; | 902 key.error = SrtpFilter::ERROR_AUTH; |
| 902 break; | 903 break; |
| 903 case err_status_replay_fail: | 904 case srtp_err_status_replay_fail: |
| 904 case err_status_replay_old: | 905 case srtp_err_status_replay_old: |
| 905 key.error = SrtpFilter::ERROR_REPLAY; | 906 key.error = SrtpFilter::ERROR_REPLAY; |
| 906 break; | 907 break; |
| 907 default: | 908 default: |
| 908 key.error = SrtpFilter::ERROR_FAIL; | 909 key.error = SrtpFilter::ERROR_FAIL; |
| 909 } | 910 } |
| 910 HandleSrtpResult(key); | 911 HandleSrtpResult(key); |
| 911 } | 912 } |
| 912 | 913 |
| 913 void SrtpStat::AddProtectRtcpResult(int result) { | 914 void SrtpStat::AddProtectRtcpResult(int result) { |
| 914 AddProtectRtpResult(0U, result); | 915 AddProtectRtpResult(0U, result); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 SrtpNotAvailable(__FUNCTION__); | 961 SrtpNotAvailable(__FUNCTION__); |
| 961 } | 962 } |
| 962 | 963 |
| 963 void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) { | 964 void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) { |
| 964 SrtpNotAvailable(__FUNCTION__); | 965 SrtpNotAvailable(__FUNCTION__); |
| 965 } | 966 } |
| 966 | 967 |
| 967 #endif // HAVE_SRTP | 968 #endif // HAVE_SRTP |
| 968 | 969 |
| 969 } // namespace cricket | 970 } // namespace cricket |
| OLD | NEW |