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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const std::string& old_pwd, | 51 const std::string& old_pwd, |
52 const std::string& new_ufrag, | 52 const std::string& new_ufrag, |
53 const std::string& new_pwd) { | 53 const std::string& new_pwd) { |
54 // The standard (RFC 5245 Section 9.1.1.1) says that ICE restarts MUST change | 54 // The standard (RFC 5245 Section 9.1.1.1) says that ICE restarts MUST change |
55 // both the ufrag and password. However, section 9.2.1.1 says changing the | 55 // both the ufrag and password. However, section 9.2.1.1 says changing the |
56 // ufrag OR password indicates an ICE restart. So, to keep compatibility with | 56 // ufrag OR password indicates an ICE restart. So, to keep compatibility with |
57 // endpoints that only change one, we'll treat this as an ICE restart. | 57 // endpoints that only change one, we'll treat this as an ICE restart. |
58 return (old_ufrag != new_ufrag) || (old_pwd != new_pwd); | 58 return (old_ufrag != new_ufrag) || (old_pwd != new_pwd); |
59 } | 59 } |
60 | 60 |
61 static bool IceCredentialsChanged(const TransportDescription& old_desc, | |
62 const TransportDescription& new_desc) { | |
63 return IceCredentialsChanged(old_desc.ice_ufrag, old_desc.ice_pwd, | |
64 new_desc.ice_ufrag, new_desc.ice_pwd); | |
65 } | |
66 | |
67 Transport::Transport(const std::string& name, PortAllocator* allocator) | 61 Transport::Transport(const std::string& name, PortAllocator* allocator) |
68 : name_(name), allocator_(allocator) {} | 62 : name_(name), allocator_(allocator) {} |
69 | 63 |
70 Transport::~Transport() { | 64 Transport::~Transport() { |
71 RTC_DCHECK(channels_destroyed_); | 65 RTC_DCHECK(channels_destroyed_); |
72 } | 66 } |
73 | 67 |
74 void Transport::SetIceRole(IceRole role) { | 68 void Transport::SetIceRole(IceRole role) { |
75 ice_role_ = role; | 69 ice_role_ = role; |
76 for (const auto& kv : channels_) { | 70 for (const auto& kv : channels_) { |
(...skipping 21 matching lines...) Expand all Loading... |
98 const TransportDescription& description, | 92 const TransportDescription& description, |
99 ContentAction action, | 93 ContentAction action, |
100 std::string* error_desc) { | 94 std::string* error_desc) { |
101 bool ret = true; | 95 bool ret = true; |
102 | 96 |
103 if (!VerifyIceParams(description)) { | 97 if (!VerifyIceParams(description)) { |
104 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length", | 98 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length", |
105 error_desc); | 99 error_desc); |
106 } | 100 } |
107 | 101 |
108 if (local_description_ && | |
109 IceCredentialsChanged(*local_description_, description)) { | |
110 IceRole new_ice_role = | |
111 (action == CA_OFFER) ? ICEROLE_CONTROLLING : ICEROLE_CONTROLLED; | |
112 | |
113 // It must be called before ApplyLocalTransportDescription, which may | |
114 // trigger an ICE restart and depends on the new ICE role. | |
115 SetIceRole(new_ice_role); | |
116 } | |
117 | |
118 local_description_.reset(new TransportDescription(description)); | 102 local_description_.reset(new TransportDescription(description)); |
119 | 103 |
120 for (const auto& kv : channels_) { | 104 for (const auto& kv : channels_) { |
121 ret &= ApplyLocalTransportDescription(kv.second, error_desc); | 105 ret &= ApplyLocalTransportDescription(kv.second, error_desc); |
122 } | 106 } |
123 if (!ret) { | 107 if (!ret) { |
124 return false; | 108 return false; |
125 } | 109 } |
126 | 110 |
127 // If PRANSWER/ANSWER is set, we should decide transport protocol type. | 111 // If PRANSWER/ANSWER is set, we should decide transport protocol type. |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 482 } |
499 | 483 |
500 // If local is passive, local will act as server. | 484 // If local is passive, local will act as server. |
501 } | 485 } |
502 | 486 |
503 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER; | 487 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER; |
504 return true; | 488 return true; |
505 } | 489 } |
506 | 490 |
507 } // namespace cricket | 491 } // namespace cricket |
OLD | NEW |