OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // occurs. | 291 // occurs. |
292 // | 292 // |
293 // This and the below method can be called safely from any thread as long as | 293 // This and the below method can be called safely from any thread as long as |
294 // SetXTransportDescription is not in progress. | 294 // SetXTransportDescription is not in progress. |
295 void SetNeedsIceRestartFlag(); | 295 void SetNeedsIceRestartFlag(); |
296 // Returns true if the ICE restart flag above was set, and no ICE restart has | 296 // Returns true if the ICE restart flag above was set, and no ICE restart has |
297 // occurred yet for this transport (by applying a local description with | 297 // occurred yet for this transport (by applying a local description with |
298 // changed ufrag/password). | 298 // changed ufrag/password). |
299 bool NeedsIceRestart() const; | 299 bool NeedsIceRestart() const; |
300 | 300 |
301 void GetSslRole(rtc::SSLRole* ssl_role) const; | 301 // Returns role if negotiated, or empty Optional if it hasn't been negotiated |
| 302 // yet. |
| 303 rtc::Optional<rtc::SSLRole> GetSslRole() const; |
302 | 304 |
303 // TODO(deadbeef): Make this const. See comment in transportcontroller.h. | 305 // TODO(deadbeef): Make this const. See comment in transportcontroller.h. |
304 bool GetStats(TransportStats* stats); | 306 bool GetStats(TransportStats* stats); |
305 | 307 |
306 // The current local transport description, possibly used | 308 // The current local transport description, possibly used |
307 // by the transport controller. | 309 // by the transport controller. |
308 const TransportDescription* local_description() const { | 310 const TransportDescription* local_description() const { |
309 return local_description_.get(); | 311 return local_description_.get(); |
310 } | 312 } |
311 | 313 |
312 // The current remote transport description, possibly used | 314 // The current remote transport description, possibly used |
313 // by the transport controller. | 315 // by the transport controller. |
314 const TransportDescription* remote_description() const { | 316 const TransportDescription* remote_description() const { |
315 return remote_description_.get(); | 317 return remote_description_.get(); |
316 } | 318 } |
317 | 319 |
318 // TODO(deadbeef): The methods below are only public for testing. Should make | 320 // TODO(deadbeef): The methods below are only public for testing. Should make |
319 // them utility functions or objects so they can be tested independently from | 321 // them utility functions or objects so they can be tested independently from |
320 // this class. | 322 // this class. |
321 | 323 |
322 // Returns false if the certificate's identity does not match the fingerprint, | 324 // Returns false if the certificate's identity does not match the fingerprint, |
323 // or either is NULL. | 325 // or either is NULL. |
324 bool VerifyCertificateFingerprint(const rtc::RTCCertificate* certificate, | 326 bool VerifyCertificateFingerprint(const rtc::RTCCertificate* certificate, |
325 const rtc::SSLFingerprint* fingerprint, | 327 const rtc::SSLFingerprint* fingerprint, |
326 std::string* error_desc) const; | 328 std::string* error_desc) const; |
327 | 329 |
328 // Negotiates the SSL role based off the offer and answer as specified by | |
329 // RFC 4145, section-4.1. Returns false if the SSL role cannot be determined | |
330 // from the local description and remote description. | |
331 bool NegotiateRole(ContentAction local_role, | |
332 rtc::SSLRole* ssl_role, | |
333 std::string* error_desc) const; | |
334 | |
335 private: | 330 private: |
336 // Negotiates the transport parameters based on the current local and remote | 331 // Negotiates the transport parameters based on the current local and remote |
337 // transport description, such as the ICE role to use, and whether DTLS | 332 // transport description, such as the ICE role to use, and whether DTLS |
338 // should be activated. | 333 // should be activated. |
339 // | 334 // |
340 // Called when an answer TransportDescription is applied. | 335 // Called when an answer TransportDescription is applied. |
341 bool NegotiateTransportDescription(ContentAction local_role, | 336 bool NegotiateTransportDescription(ContentAction local_description_type, |
342 std::string* error_desc); | 337 std::string* error_desc); |
343 | 338 |
| 339 // Negotiates the SSL role based off the offer and answer as specified by |
| 340 // RFC 4145, section-4.1. Returns false if the SSL role cannot be determined |
| 341 // from the local description and remote description. |
| 342 bool NegotiateRole(ContentAction local_description_type, |
| 343 std::string* error_desc); |
| 344 |
344 // Pushes down the transport parameters from the local description, such | 345 // Pushes down the transport parameters from the local description, such |
345 // as the ICE ufrag and pwd. | 346 // as the ICE ufrag and pwd. |
346 bool ApplyLocalTransportDescription(DtlsTransportInternal* dtls_transport, | 347 bool ApplyLocalTransportDescription(DtlsTransportInternal* dtls_transport, |
347 std::string* error_desc); | 348 std::string* error_desc); |
348 | 349 |
349 // Pushes down the transport parameters from the remote description to the | 350 // Pushes down the transport parameters from the remote description to the |
350 // transport channel. | 351 // transport channel. |
351 bool ApplyRemoteTransportDescription(DtlsTransportInternal* dtls_transport, | 352 bool ApplyRemoteTransportDescription(DtlsTransportInternal* dtls_transport, |
352 std::string* error_desc); | 353 std::string* error_desc); |
353 | 354 |
354 // Pushes down the transport parameters obtained via negotiation. | 355 // Pushes down the transport parameters obtained via negotiation. |
355 bool ApplyNegotiatedTransportDescription( | 356 bool ApplyNegotiatedTransportDescription( |
356 DtlsTransportInternal* dtls_transport, | 357 DtlsTransportInternal* dtls_transport, |
357 std::string* error_desc); | 358 std::string* error_desc); |
358 | 359 |
359 const std::string mid_; | 360 const std::string mid_; |
360 // needs-ice-restart bit as described in JSEP. | 361 // needs-ice-restart bit as described in JSEP. |
361 bool needs_ice_restart_ = false; | 362 bool needs_ice_restart_ = false; |
362 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 363 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
363 rtc::SSLRole secure_role_ = rtc::SSL_CLIENT; | 364 rtc::Optional<rtc::SSLRole> ssl_role_; |
364 std::unique_ptr<rtc::SSLFingerprint> remote_fingerprint_; | 365 std::unique_ptr<rtc::SSLFingerprint> remote_fingerprint_; |
365 std::unique_ptr<TransportDescription> local_description_; | 366 std::unique_ptr<TransportDescription> local_description_; |
366 std::unique_ptr<TransportDescription> remote_description_; | 367 std::unique_ptr<TransportDescription> remote_description_; |
367 bool local_description_set_ = false; | 368 bool local_description_set_ = false; |
368 bool remote_description_set_ = false; | 369 bool remote_description_set_ = false; |
369 | 370 |
370 // Candidate component => DTLS channel | 371 // Candidate component => DTLS channel |
371 std::map<int, DtlsTransportInternal*> channels_; | 372 std::map<int, DtlsTransportInternal*> channels_; |
372 | 373 |
373 RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransport); | 374 RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransport); |
374 }; | 375 }; |
375 | 376 |
376 } // namespace cricket | 377 } // namespace cricket |
377 | 378 |
378 #endif // WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ | 379 #endif // WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ |
OLD | NEW |