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 |
11 #ifndef WEBRTC_P2P_BASE_TURNPORT_H_ | 11 #ifndef WEBRTC_P2P_BASE_TURNPORT_H_ |
12 #define WEBRTC_P2P_BASE_TURNPORT_H_ | 12 #define WEBRTC_P2P_BASE_TURNPORT_H_ |
13 | 13 |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <list> | 15 #include <list> |
16 #include <set> | 16 #include <set> |
17 #include <string> | 17 #include <string> |
18 | 18 |
19 #include "webrtc/base/asyncinvoker.h" | |
20 #include "webrtc/base/asyncpacketsocket.h" | |
21 #include "webrtc/p2p/base/port.h" | 19 #include "webrtc/p2p/base/port.h" |
22 #include "webrtc/p2p/client/basicportallocator.h" | 20 #include "webrtc/p2p/client/basicportallocator.h" |
| 21 #include "webrtc/base/asyncpacketsocket.h" |
23 | 22 |
24 namespace rtc { | 23 namespace rtc { |
25 class AsyncResolver; | 24 class AsyncResolver; |
26 class SignalThread; | 25 class SignalThread; |
27 } | 26 } |
28 | 27 |
29 namespace cricket { | 28 namespace cricket { |
30 | 29 |
31 extern const char TURN_PORT_TYPE[]; | 30 extern const char TURN_PORT_TYPE[]; |
32 class TurnAllocateRequest; | 31 class TurnAllocateRequest; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const std::string& nonce() const { return nonce_; } | 115 const std::string& nonce() const { return nonce_; } |
117 | 116 |
118 int error() const { return error_; } | 117 int error() const { return error_; } |
119 | 118 |
120 void OnAllocateMismatch(); | 119 void OnAllocateMismatch(); |
121 | 120 |
122 rtc::AsyncPacketSocket* socket() const { | 121 rtc::AsyncPacketSocket* socket() const { |
123 return socket_; | 122 return socket_; |
124 } | 123 } |
125 | 124 |
126 // For testing only. | |
127 rtc::AsyncInvoker* invoker() { return &invoker_; } | |
128 | |
129 // Signal with resolved server address. | 125 // Signal with resolved server address. |
130 // Parameters are port, server address and resolved server address. | 126 // Parameters are port, server address and resolved server address. |
131 // This signal will be sent only if server address is resolved successfully. | 127 // This signal will be sent only if server address is resolved successfully. |
132 sigslot::signal3<TurnPort*, | 128 sigslot::signal3<TurnPort*, |
133 const rtc::SocketAddress&, | 129 const rtc::SocketAddress&, |
134 const rtc::SocketAddress&> SignalResolvedServerAddress; | 130 const rtc::SocketAddress&> SignalResolvedServerAddress; |
135 | 131 |
136 // This signal is only for testing purpose. | 132 // This signal is only for testing purpose. |
137 sigslot::signal3<TurnPort*, const rtc::SocketAddress&, int> | 133 sigslot::signal3<TurnPort*, const rtc::SocketAddress&, int> |
138 SignalCreatePermissionResult; | 134 SignalCreatePermissionResult; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 bool ScheduleRefresh(int lifetime); | 208 bool ScheduleRefresh(int lifetime); |
213 void SendRequest(StunRequest* request, int delay); | 209 void SendRequest(StunRequest* request, int delay); |
214 int Send(const void* data, size_t size, | 210 int Send(const void* data, size_t size, |
215 const rtc::PacketOptions& options); | 211 const rtc::PacketOptions& options); |
216 void UpdateHash(); | 212 void UpdateHash(); |
217 bool UpdateNonce(StunMessage* response); | 213 bool UpdateNonce(StunMessage* response); |
218 | 214 |
219 bool HasPermission(const rtc::IPAddress& ipaddr) const; | 215 bool HasPermission(const rtc::IPAddress& ipaddr) const; |
220 TurnEntry* FindEntry(const rtc::SocketAddress& address) const; | 216 TurnEntry* FindEntry(const rtc::SocketAddress& address) const; |
221 TurnEntry* FindEntry(int channel_id) const; | 217 TurnEntry* FindEntry(int channel_id) const; |
222 void CreateOrRefreshEntry(const rtc::SocketAddress& address); | 218 TurnEntry* CreateEntry(const rtc::SocketAddress& address); |
223 void DestroyEntry(TurnEntry* entry); | 219 void DestroyEntry(const rtc::SocketAddress& address); |
224 // Destroys the entry only if |timestamp| matches the destruction timestamp | |
225 // in |entry|. | |
226 void DestroyEntryIfNotCancelled(TurnEntry* entry, uint32_t timestamp); | |
227 void ScheduleEntryDestruction(TurnEntry* entry); | |
228 void CancelEntryDestruction(TurnEntry* entry); | |
229 void OnConnectionDestroyed(Connection* conn); | 220 void OnConnectionDestroyed(Connection* conn); |
230 | 221 |
231 ProtocolAddress server_address_; | 222 ProtocolAddress server_address_; |
232 RelayCredentials credentials_; | 223 RelayCredentials credentials_; |
233 AttemptedServerSet attempted_server_addresses_; | 224 AttemptedServerSet attempted_server_addresses_; |
234 | 225 |
235 rtc::AsyncPacketSocket* socket_; | 226 rtc::AsyncPacketSocket* socket_; |
236 SocketOptionsMap socket_options_; | 227 SocketOptionsMap socket_options_; |
237 rtc::AsyncResolverInterface* resolver_; | 228 rtc::AsyncResolverInterface* resolver_; |
238 int error_; | 229 int error_; |
239 | 230 |
240 StunRequestManager request_manager_; | 231 StunRequestManager request_manager_; |
241 std::string realm_; // From 401/438 response message. | 232 std::string realm_; // From 401/438 response message. |
242 std::string nonce_; // From 401/438 response message. | 233 std::string nonce_; // From 401/438 response message. |
243 std::string hash_; // Digest of username:realm:password | 234 std::string hash_; // Digest of username:realm:password |
244 | 235 |
245 int next_channel_number_; | 236 int next_channel_number_; |
246 EntryList entries_; | 237 EntryList entries_; |
247 | 238 |
248 PortState state_; | 239 PortState state_; |
249 // By default the value will be set to 0. This value will be used in | 240 // By default the value will be set to 0. This value will be used in |
250 // calculating the candidate priority. | 241 // calculating the candidate priority. |
251 int server_priority_; | 242 int server_priority_; |
252 | 243 |
253 // The number of retries made due to allocate mismatch error. | 244 // The number of retries made due to allocate mismatch error. |
254 size_t allocate_mismatch_retries_; | 245 size_t allocate_mismatch_retries_; |
255 | 246 |
256 rtc::AsyncInvoker invoker_; | |
257 | |
258 friend class TurnEntry; | 247 friend class TurnEntry; |
259 friend class TurnAllocateRequest; | 248 friend class TurnAllocateRequest; |
260 friend class TurnRefreshRequest; | 249 friend class TurnRefreshRequest; |
261 friend class TurnCreatePermissionRequest; | 250 friend class TurnCreatePermissionRequest; |
262 friend class TurnChannelBindRequest; | 251 friend class TurnChannelBindRequest; |
263 }; | 252 }; |
264 | 253 |
265 } // namespace cricket | 254 } // namespace cricket |
266 | 255 |
267 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ | 256 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ |
OLD | NEW |