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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // | 75 // |
76 // - Data written to DtlsTransportChannelWrapper is passed either to | 76 // - Data written to DtlsTransportChannelWrapper is passed either to |
77 // downward_ or directly to channel_, depending on whether DTLS is | 77 // downward_ or directly to channel_, depending on whether DTLS is |
78 // negotiated and whether the flags include PF_SRTP_BYPASS | 78 // negotiated and whether the flags include PF_SRTP_BYPASS |
79 // | 79 // |
80 // - The SSLStreamAdapter writes to downward_->Write() | 80 // - The SSLStreamAdapter writes to downward_->Write() |
81 // which translates it into packet writes on channel_. | 81 // which translates it into packet writes on channel_. |
82 class DtlsTransportChannelWrapper : public TransportChannelImpl { | 82 class DtlsTransportChannelWrapper : public TransportChannelImpl { |
83 public: | 83 public: |
84 // The parameters here are: | 84 // The parameters here are: |
85 // transport -- the DtlsTransport that created us | |
86 // channel -- the TransportChannel we are wrapping | 85 // channel -- the TransportChannel we are wrapping |
87 DtlsTransportChannelWrapper(Transport* transport, | 86 explicit DtlsTransportChannelWrapper(TransportChannelImpl* channel); |
88 TransportChannelImpl* channel); | |
89 ~DtlsTransportChannelWrapper() override; | 87 ~DtlsTransportChannelWrapper() override; |
90 | 88 |
91 void SetIceRole(IceRole role) override { channel_->SetIceRole(role); } | 89 void SetIceRole(IceRole role) override { channel_->SetIceRole(role); } |
92 IceRole GetIceRole() const override { return channel_->GetIceRole(); } | 90 IceRole GetIceRole() const override { return channel_->GetIceRole(); } |
93 bool SetLocalCertificate( | 91 bool SetLocalCertificate( |
94 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override; | 92 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override; |
95 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override; | 93 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override; |
96 | 94 |
97 bool SetRemoteFingerprint(const std::string& digest_alg, | 95 bool SetRemoteFingerprint(const std::string& digest_alg, |
98 const uint8_t* digest, | 96 const uint8_t* digest, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 uint8_t* result, | 150 uint8_t* result, |
153 size_t result_len) override { | 151 size_t result_len) override { |
154 return (dtls_.get()) ? dtls_->ExportKeyingMaterial(label, context, | 152 return (dtls_.get()) ? dtls_->ExportKeyingMaterial(label, context, |
155 context_len, | 153 context_len, |
156 use_context, | 154 use_context, |
157 result, result_len) | 155 result, result_len) |
158 : false; | 156 : false; |
159 } | 157 } |
160 | 158 |
161 // TransportChannelImpl calls. | 159 // TransportChannelImpl calls. |
162 Transport* GetTransport() override { return transport_; } | |
163 | |
164 TransportChannelState GetState() const override { | 160 TransportChannelState GetState() const override { |
165 return channel_->GetState(); | 161 return channel_->GetState(); |
166 } | 162 } |
167 void SetIceTiebreaker(uint64_t tiebreaker) override { | 163 void SetIceTiebreaker(uint64_t tiebreaker) override { |
168 channel_->SetIceTiebreaker(tiebreaker); | 164 channel_->SetIceTiebreaker(tiebreaker); |
169 } | 165 } |
170 void SetIceCredentials(const std::string& ice_ufrag, | 166 void SetIceCredentials(const std::string& ice_ufrag, |
171 const std::string& ice_pwd) override { | 167 const std::string& ice_pwd) override { |
172 channel_->SetIceCredentials(ice_ufrag, ice_pwd); | 168 channel_->SetIceCredentials(ice_ufrag, ice_pwd); |
173 } | 169 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 bool SetupDtls(); | 207 bool SetupDtls(); |
212 bool MaybeStartDtls(); | 208 bool MaybeStartDtls(); |
213 bool HandleDtlsPacket(const char* data, size_t size); | 209 bool HandleDtlsPacket(const char* data, size_t size); |
214 void OnGatheringState(TransportChannelImpl* channel); | 210 void OnGatheringState(TransportChannelImpl* channel); |
215 void OnCandidateGathered(TransportChannelImpl* channel, const Candidate& c); | 211 void OnCandidateGathered(TransportChannelImpl* channel, const Candidate& c); |
216 void OnRoleConflict(TransportChannelImpl* channel); | 212 void OnRoleConflict(TransportChannelImpl* channel); |
217 void OnRouteChange(TransportChannel* channel, const Candidate& candidate); | 213 void OnRouteChange(TransportChannel* channel, const Candidate& candidate); |
218 void OnConnectionRemoved(TransportChannelImpl* channel); | 214 void OnConnectionRemoved(TransportChannelImpl* channel); |
219 void Reconnect(); | 215 void Reconnect(); |
220 | 216 |
221 Transport* transport_; // The transport_ that created us. | |
222 rtc::Thread* worker_thread_; // Everything should occur on this thread. | 217 rtc::Thread* worker_thread_; // Everything should occur on this thread. |
223 // Underlying channel, owned by transport_. | 218 // Underlying channel, not owned by this class. |
224 TransportChannelImpl* const channel_; | 219 TransportChannelImpl* const channel_; |
225 rtc::scoped_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream | 220 rtc::scoped_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream |
226 StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_. | 221 StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_. |
227 std::vector<int> srtp_ciphers_; // SRTP ciphers to use with DTLS. | 222 std::vector<int> srtp_ciphers_; // SRTP ciphers to use with DTLS. |
228 bool dtls_active_ = false; | 223 bool dtls_active_ = false; |
229 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate_; | 224 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate_; |
230 rtc::SSLRole ssl_role_; | 225 rtc::SSLRole ssl_role_; |
231 rtc::SSLProtocolVersion ssl_max_version_; | 226 rtc::SSLProtocolVersion ssl_max_version_; |
232 rtc::Buffer remote_fingerprint_value_; | 227 rtc::Buffer remote_fingerprint_value_; |
233 std::string remote_fingerprint_algorithm_; | 228 std::string remote_fingerprint_algorithm_; |
234 | 229 |
235 RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransportChannelWrapper); | 230 RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransportChannelWrapper); |
236 }; | 231 }; |
237 | 232 |
238 } // namespace cricket | 233 } // namespace cricket |
239 | 234 |
240 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_ | 235 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_ |
OLD | NEW |