OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 SignalCreatePermissionResult; | 145 SignalCreatePermissionResult; |
146 void FlushRequests(int msg_type) { request_manager_.Flush(msg_type); } | 146 void FlushRequests(int msg_type) { request_manager_.Flush(msg_type); } |
147 bool HasRequests() { return !request_manager_.empty(); } | 147 bool HasRequests() { return !request_manager_.empty(); } |
148 void set_credentials(RelayCredentials& credentials) { | 148 void set_credentials(RelayCredentials& credentials) { |
149 credentials_ = credentials; | 149 credentials_ = credentials; |
150 } | 150 } |
151 // Finds the turn entry with |address| and sets its channel id. | 151 // Finds the turn entry with |address| and sets its channel id. |
152 // Returns true if the entry is found. | 152 // Returns true if the entry is found. |
153 bool SetEntryChannelId(const rtc::SocketAddress& address, int channel_id); | 153 bool SetEntryChannelId(const rtc::SocketAddress& address, int channel_id); |
154 | 154 |
| 155 // For testing only. |
| 156 void set_nonce(const std::string& nonce) { nonce_ = nonce; } |
| 157 void set_hash(const std::string& hash) { hash_ = hash; } |
| 158 |
155 protected: | 159 protected: |
156 TurnPort(rtc::Thread* thread, | 160 TurnPort(rtc::Thread* thread, |
157 rtc::PacketSocketFactory* factory, | 161 rtc::PacketSocketFactory* factory, |
158 rtc::Network* network, | 162 rtc::Network* network, |
159 rtc::AsyncPacketSocket* socket, | 163 rtc::AsyncPacketSocket* socket, |
160 const std::string& username, | 164 const std::string& username, |
161 const std::string& password, | 165 const std::string& password, |
162 const ProtocolAddress& server_address, | 166 const ProtocolAddress& server_address, |
163 const RelayCredentials& credentials, | 167 const RelayCredentials& credentials, |
164 int server_priority, | 168 int server_priority, |
(...skipping 20 matching lines...) Expand all Loading... |
185 MSG_REFRESH_ERROR | 189 MSG_REFRESH_ERROR |
186 }; | 190 }; |
187 | 191 |
188 typedef std::list<TurnEntry*> EntryList; | 192 typedef std::list<TurnEntry*> EntryList; |
189 typedef std::map<rtc::Socket::Option, int> SocketOptionsMap; | 193 typedef std::map<rtc::Socket::Option, int> SocketOptionsMap; |
190 typedef std::set<rtc::SocketAddress> AttemptedServerSet; | 194 typedef std::set<rtc::SocketAddress> AttemptedServerSet; |
191 | 195 |
192 virtual void OnMessage(rtc::Message* pmsg); | 196 virtual void OnMessage(rtc::Message* pmsg); |
193 | 197 |
194 bool CreateTurnClientSocket(); | 198 bool CreateTurnClientSocket(); |
195 | |
196 void set_nonce(const std::string& nonce) { nonce_ = nonce; } | |
197 void set_realm(const std::string& realm) { | 199 void set_realm(const std::string& realm) { |
198 if (realm != realm_) { | 200 if (realm != realm_) { |
199 realm_ = realm; | 201 realm_ = realm; |
200 UpdateHash(); | 202 UpdateHash(); |
201 } | 203 } |
202 } | 204 } |
203 | 205 |
204 // Shuts down the turn port, usually because of some fatal errors. | 206 // Shuts down the turn port, usually because of some fatal errors. |
205 void Close(); | 207 void Close(); |
206 void OnTurnRefreshError(); | 208 void OnTurnRefreshError(); |
(...skipping 18 matching lines...) Expand all Loading... |
225 void DispatchPacket(const char* data, size_t size, | 227 void DispatchPacket(const char* data, size_t size, |
226 const rtc::SocketAddress& remote_addr, | 228 const rtc::SocketAddress& remote_addr, |
227 ProtocolType proto, const rtc::PacketTime& packet_time); | 229 ProtocolType proto, const rtc::PacketTime& packet_time); |
228 | 230 |
229 bool ScheduleRefresh(int lifetime); | 231 bool ScheduleRefresh(int lifetime); |
230 void SendRequest(StunRequest* request, int delay); | 232 void SendRequest(StunRequest* request, int delay); |
231 int Send(const void* data, size_t size, | 233 int Send(const void* data, size_t size, |
232 const rtc::PacketOptions& options); | 234 const rtc::PacketOptions& options); |
233 void UpdateHash(); | 235 void UpdateHash(); |
234 bool UpdateNonce(StunMessage* response); | 236 bool UpdateNonce(StunMessage* response); |
| 237 void ResetNonce(); |
235 | 238 |
236 bool HasPermission(const rtc::IPAddress& ipaddr) const; | 239 bool HasPermission(const rtc::IPAddress& ipaddr) const; |
237 TurnEntry* FindEntry(const rtc::SocketAddress& address) const; | 240 TurnEntry* FindEntry(const rtc::SocketAddress& address) const; |
238 TurnEntry* FindEntry(int channel_id) const; | 241 TurnEntry* FindEntry(int channel_id) const; |
239 bool EntryExists(TurnEntry* e); | 242 bool EntryExists(TurnEntry* e); |
240 void CreateOrRefreshEntry(const rtc::SocketAddress& address); | 243 void CreateOrRefreshEntry(const rtc::SocketAddress& address); |
241 void DestroyEntry(TurnEntry* entry); | 244 void DestroyEntry(TurnEntry* entry); |
242 // Destroys the entry only if |timestamp| matches the destruction timestamp | 245 // Destroys the entry only if |timestamp| matches the destruction timestamp |
243 // in |entry|. | 246 // in |entry|. |
244 void DestroyEntryIfNotCancelled(TurnEntry* entry, uint32_t timestamp); | 247 void DestroyEntryIfNotCancelled(TurnEntry* entry, uint32_t timestamp); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 friend class TurnEntry; | 283 friend class TurnEntry; |
281 friend class TurnAllocateRequest; | 284 friend class TurnAllocateRequest; |
282 friend class TurnRefreshRequest; | 285 friend class TurnRefreshRequest; |
283 friend class TurnCreatePermissionRequest; | 286 friend class TurnCreatePermissionRequest; |
284 friend class TurnChannelBindRequest; | 287 friend class TurnChannelBindRequest; |
285 }; | 288 }; |
286 | 289 |
287 } // namespace cricket | 290 } // namespace cricket |
288 | 291 |
289 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ | 292 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ |
OLD | NEW |