| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 24 // We don't pull the RTP constants from rtputils.h, to avoid a layer violation. | 24 // We don't pull the RTP constants from rtputils.h, to avoid a layer violation. |
| 25 static const size_t kDtlsRecordHeaderLen = 13; | 25 static const size_t kDtlsRecordHeaderLen = 13; |
| 26 static const size_t kMaxDtlsPacketLen = 2048; | 26 static const size_t kMaxDtlsPacketLen = 2048; |
| 27 static const size_t kMinRtpPacketLen = 12; | 27 static const size_t kMinRtpPacketLen = 12; |
| 28 | 28 |
| 29 // Maximum number of pending packets in the queue. Packets are read immediately | 29 // Maximum number of pending packets in the queue. Packets are read immediately |
| 30 // after they have been written, so a capacity of "1" is sufficient. | 30 // after they have been written, so a capacity of "1" is sufficient. |
| 31 static const size_t kMaxPendingPackets = 1; | 31 static const size_t kMaxPendingPackets = 1; |
| 32 | 32 |
| 33 static bool IsDtlsPacket(const char* data, size_t len) { | 33 static bool IsDtlsPacket(const char* data, size_t len) { |
| 34 const uint8* u = reinterpret_cast<const uint8*>(data); | 34 const uint8_t* u = reinterpret_cast<const uint8_t*>(data); |
| 35 return (len >= kDtlsRecordHeaderLen && (u[0] > 19 && u[0] < 64)); | 35 return (len >= kDtlsRecordHeaderLen && (u[0] > 19 && u[0] < 64)); |
| 36 } | 36 } |
| 37 static bool IsRtpPacket(const char* data, size_t len) { | 37 static bool IsRtpPacket(const char* data, size_t len) { |
| 38 const uint8* u = reinterpret_cast<const uint8*>(data); | 38 const uint8_t* u = reinterpret_cast<const uint8_t*>(data); |
| 39 return (len >= kMinRtpPacketLen && (u[0] & 0xC0) == 0x80); | 39 return (len >= kMinRtpPacketLen && (u[0] & 0xC0) == 0x80); |
| 40 } | 40 } |
| 41 | 41 |
| 42 StreamInterfaceChannel::StreamInterfaceChannel(TransportChannel* channel) | 42 StreamInterfaceChannel::StreamInterfaceChannel(TransportChannel* channel) |
| 43 : channel_(channel), | 43 : channel_(channel), |
| 44 state_(rtc::SS_OPEN), | 44 state_(rtc::SS_OPEN), |
| 45 packets_(kMaxPendingPackets, kMaxDtlsPacketLen) { | 45 packets_(kMaxPendingPackets, kMaxDtlsPacketLen) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 rtc::StreamResult StreamInterfaceChannel::Read(void* buffer, | 48 rtc::StreamResult StreamInterfaceChannel::Read(void* buffer, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 bool DtlsTransportChannelWrapper::GetSslCipher(std::string* cipher) { | 191 bool DtlsTransportChannelWrapper::GetSslCipher(std::string* cipher) { |
| 192 if (dtls_state_ != STATE_OPEN) { | 192 if (dtls_state_ != STATE_OPEN) { |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| 195 | 195 |
| 196 return dtls_->GetSslCipher(cipher); | 196 return dtls_->GetSslCipher(cipher); |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool DtlsTransportChannelWrapper::SetRemoteFingerprint( | 199 bool DtlsTransportChannelWrapper::SetRemoteFingerprint( |
| 200 const std::string& digest_alg, | 200 const std::string& digest_alg, |
| 201 const uint8* digest, | 201 const uint8_t* digest, |
| 202 size_t digest_len) { | 202 size_t digest_len) { |
| 203 | |
| 204 rtc::Buffer remote_fingerprint_value(digest, digest_len); | 203 rtc::Buffer remote_fingerprint_value(digest, digest_len); |
| 205 | 204 |
| 206 if (dtls_state_ != STATE_NONE && | 205 if (dtls_state_ != STATE_NONE && |
| 207 remote_fingerprint_value_ == remote_fingerprint_value && | 206 remote_fingerprint_value_ == remote_fingerprint_value && |
| 208 !digest_alg.empty()) { | 207 !digest_alg.empty()) { |
| 209 // This may happen during renegotiation. | 208 // This may happen during renegotiation. |
| 210 LOG_J(LS_INFO, this) << "Ignoring identical remote DTLS fingerprint"; | 209 LOG_J(LS_INFO, this) << "Ignoring identical remote DTLS fingerprint"; |
| 211 return true; | 210 return true; |
| 212 } | 211 } |
| 213 | 212 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 dtls_state_ = STATE_STARTED; | 564 dtls_state_ = STATE_STARTED; |
| 566 } | 565 } |
| 567 return true; | 566 return true; |
| 568 } | 567 } |
| 569 | 568 |
| 570 // Called from OnReadPacket when a DTLS packet is received. | 569 // Called from OnReadPacket when a DTLS packet is received. |
| 571 bool DtlsTransportChannelWrapper::HandleDtlsPacket(const char* data, | 570 bool DtlsTransportChannelWrapper::HandleDtlsPacket(const char* data, |
| 572 size_t size) { | 571 size_t size) { |
| 573 // Sanity check we're not passing junk that | 572 // Sanity check we're not passing junk that |
| 574 // just looks like DTLS. | 573 // just looks like DTLS. |
| 575 const uint8* tmp_data = reinterpret_cast<const uint8* >(data); | 574 const uint8_t* tmp_data = reinterpret_cast<const uint8_t*>(data); |
| 576 size_t tmp_size = size; | 575 size_t tmp_size = size; |
| 577 while (tmp_size > 0) { | 576 while (tmp_size > 0) { |
| 578 if (tmp_size < kDtlsRecordHeaderLen) | 577 if (tmp_size < kDtlsRecordHeaderLen) |
| 579 return false; // Too short for the header | 578 return false; // Too short for the header |
| 580 | 579 |
| 581 size_t record_len = (tmp_data[11] << 8) | (tmp_data[12]); | 580 size_t record_len = (tmp_data[11] << 8) | (tmp_data[12]); |
| 582 if ((record_len + kDtlsRecordHeaderLen) > tmp_size) | 581 if ((record_len + kDtlsRecordHeaderLen) > tmp_size) |
| 583 return false; // Body too short | 582 return false; // Body too short |
| 584 | 583 |
| 585 tmp_data += record_len + kDtlsRecordHeaderLen; | 584 tmp_data += record_len + kDtlsRecordHeaderLen; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 SignalRouteChange(this, candidate); | 620 SignalRouteChange(this, candidate); |
| 622 } | 621 } |
| 623 | 622 |
| 624 void DtlsTransportChannelWrapper::OnConnectionRemoved( | 623 void DtlsTransportChannelWrapper::OnConnectionRemoved( |
| 625 TransportChannelImpl* channel) { | 624 TransportChannelImpl* channel) { |
| 626 ASSERT(channel == channel_); | 625 ASSERT(channel == channel_); |
| 627 SignalConnectionRemoved(this); | 626 SignalConnectionRemoved(this); |
| 628 } | 627 } |
| 629 | 628 |
| 630 } // namespace cricket | 629 } // namespace cricket |
| OLD | NEW |