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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 bool DtlsTransportChannelWrapper::GetSslCipherSuite(uint16_t* cipher) { | 189 bool DtlsTransportChannelWrapper::GetSslCipherSuite(uint16_t* cipher) { |
190 if (dtls_state_ != STATE_OPEN) { | 190 if (dtls_state_ != STATE_OPEN) { |
191 return false; | 191 return false; |
192 } | 192 } |
193 | 193 |
194 return dtls_->GetSslCipherSuite(cipher); | 194 return dtls_->GetSslCipherSuite(cipher); |
195 } | 195 } |
196 | 196 |
197 bool DtlsTransportChannelWrapper::SetRemoteFingerprint( | 197 bool DtlsTransportChannelWrapper::SetRemoteFingerprint( |
198 const std::string& digest_alg, | 198 const std::string& digest_alg, |
199 const uint8* digest, | 199 const uint8_t* digest, |
200 size_t digest_len) { | 200 size_t digest_len) { |
201 | |
202 rtc::Buffer remote_fingerprint_value(digest, digest_len); | 201 rtc::Buffer remote_fingerprint_value(digest, digest_len); |
203 | 202 |
204 if (dtls_state_ != STATE_NONE && | 203 if (dtls_state_ != STATE_NONE && |
205 remote_fingerprint_value_ == remote_fingerprint_value && | 204 remote_fingerprint_value_ == remote_fingerprint_value && |
206 !digest_alg.empty()) { | 205 !digest_alg.empty()) { |
207 // This may happen during renegotiation. | 206 // This may happen during renegotiation. |
208 LOG_J(LS_INFO, this) << "Ignoring identical remote DTLS fingerprint"; | 207 LOG_J(LS_INFO, this) << "Ignoring identical remote DTLS fingerprint"; |
209 return true; | 208 return true; |
210 } | 209 } |
211 | 210 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 dtls_state_ = STATE_STARTED; | 562 dtls_state_ = STATE_STARTED; |
564 } | 563 } |
565 return true; | 564 return true; |
566 } | 565 } |
567 | 566 |
568 // Called from OnReadPacket when a DTLS packet is received. | 567 // Called from OnReadPacket when a DTLS packet is received. |
569 bool DtlsTransportChannelWrapper::HandleDtlsPacket(const char* data, | 568 bool DtlsTransportChannelWrapper::HandleDtlsPacket(const char* data, |
570 size_t size) { | 569 size_t size) { |
571 // Sanity check we're not passing junk that | 570 // Sanity check we're not passing junk that |
572 // just looks like DTLS. | 571 // just looks like DTLS. |
573 const uint8* tmp_data = reinterpret_cast<const uint8* >(data); | 572 const uint8_t* tmp_data = reinterpret_cast<const uint8_t*>(data); |
574 size_t tmp_size = size; | 573 size_t tmp_size = size; |
575 while (tmp_size > 0) { | 574 while (tmp_size > 0) { |
576 if (tmp_size < kDtlsRecordHeaderLen) | 575 if (tmp_size < kDtlsRecordHeaderLen) |
577 return false; // Too short for the header | 576 return false; // Too short for the header |
578 | 577 |
579 size_t record_len = (tmp_data[11] << 8) | (tmp_data[12]); | 578 size_t record_len = (tmp_data[11] << 8) | (tmp_data[12]); |
580 if ((record_len + kDtlsRecordHeaderLen) > tmp_size) | 579 if ((record_len + kDtlsRecordHeaderLen) > tmp_size) |
581 return false; // Body too short | 580 return false; // Body too short |
582 | 581 |
583 tmp_data += record_len + kDtlsRecordHeaderLen; | 582 tmp_data += record_len + kDtlsRecordHeaderLen; |
(...skipping 30 matching lines...) Expand all Loading... |
614 SignalRouteChange(this, candidate); | 613 SignalRouteChange(this, candidate); |
615 } | 614 } |
616 | 615 |
617 void DtlsTransportChannelWrapper::OnConnectionRemoved( | 616 void DtlsTransportChannelWrapper::OnConnectionRemoved( |
618 TransportChannelImpl* channel) { | 617 TransportChannelImpl* channel) { |
619 ASSERT(channel == channel_); | 618 ASSERT(channel == channel_); |
620 SignalConnectionRemoved(this); | 619 SignalConnectionRemoved(this); |
621 } | 620 } |
622 | 621 |
623 } // namespace cricket | 622 } // namespace cricket |
OLD | NEW |