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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 if (!port->Init()) { | 47 if (!port->Init()) { |
48 delete port; | 48 delete port; |
49 port = NULL; | 49 port = NULL; |
50 } | 50 } |
51 return port; | 51 return port; |
52 } | 52 } |
53 | 53 |
54 static UDPPort* Create(rtc::Thread* thread, | 54 static UDPPort* Create(rtc::Thread* thread, |
55 rtc::PacketSocketFactory* factory, | 55 rtc::PacketSocketFactory* factory, |
56 rtc::Network* network, | 56 rtc::Network* network, |
57 const rtc::IPAddress& ip, | |
58 uint16_t min_port, | 57 uint16_t min_port, |
59 uint16_t max_port, | 58 uint16_t max_port, |
60 const std::string& username, | 59 const std::string& username, |
61 const std::string& password, | 60 const std::string& password, |
62 const std::string& origin, | 61 const std::string& origin, |
63 bool emit_local_for_anyaddress) { | 62 bool emit_local_for_anyaddress) { |
64 UDPPort* port = | 63 UDPPort* port = |
65 new UDPPort(thread, factory, network, ip, min_port, max_port, username, | 64 new UDPPort(thread, factory, network, min_port, max_port, username, |
66 password, origin, emit_local_for_anyaddress); | 65 password, origin, emit_local_for_anyaddress); |
67 if (!port->Init()) { | 66 if (!port->Init()) { |
68 delete port; | 67 delete port; |
69 port = NULL; | 68 port = NULL; |
70 } | 69 } |
71 return port; | 70 return port; |
72 } | 71 } |
73 | 72 |
74 virtual ~UDPPort(); | 73 virtual ~UDPPort(); |
75 | 74 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 119 } |
121 // Returns true if there is a pending request with type |msg_type|. | 120 // Returns true if there is a pending request with type |msg_type|. |
122 bool HasPendingRequest(int msg_type) { | 121 bool HasPendingRequest(int msg_type) { |
123 return requests_.HasRequest(msg_type); | 122 return requests_.HasRequest(msg_type); |
124 } | 123 } |
125 | 124 |
126 protected: | 125 protected: |
127 UDPPort(rtc::Thread* thread, | 126 UDPPort(rtc::Thread* thread, |
128 rtc::PacketSocketFactory* factory, | 127 rtc::PacketSocketFactory* factory, |
129 rtc::Network* network, | 128 rtc::Network* network, |
130 const rtc::IPAddress& ip, | |
131 uint16_t min_port, | 129 uint16_t min_port, |
132 uint16_t max_port, | 130 uint16_t max_port, |
133 const std::string& username, | 131 const std::string& username, |
134 const std::string& password, | 132 const std::string& password, |
135 const std::string& origin, | 133 const std::string& origin, |
136 bool emit_local_for_anyaddress); | 134 bool emit_local_for_anyaddress); |
137 | 135 |
138 UDPPort(rtc::Thread* thread, | 136 UDPPort(rtc::Thread* thread, |
139 rtc::PacketSocketFactory* factory, | 137 rtc::PacketSocketFactory* factory, |
140 rtc::Network* network, | 138 rtc::Network* network, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 bool emit_local_for_anyaddress_; | 250 bool emit_local_for_anyaddress_; |
253 | 251 |
254 friend class StunBindingRequest; | 252 friend class StunBindingRequest; |
255 }; | 253 }; |
256 | 254 |
257 class StunPort : public UDPPort { | 255 class StunPort : public UDPPort { |
258 public: | 256 public: |
259 static StunPort* Create(rtc::Thread* thread, | 257 static StunPort* Create(rtc::Thread* thread, |
260 rtc::PacketSocketFactory* factory, | 258 rtc::PacketSocketFactory* factory, |
261 rtc::Network* network, | 259 rtc::Network* network, |
262 const rtc::IPAddress& ip, | |
263 uint16_t min_port, | 260 uint16_t min_port, |
264 uint16_t max_port, | 261 uint16_t max_port, |
265 const std::string& username, | 262 const std::string& username, |
266 const std::string& password, | 263 const std::string& password, |
267 const ServerAddresses& servers, | 264 const ServerAddresses& servers, |
268 const std::string& origin) { | 265 const std::string& origin) { |
269 StunPort* port = new StunPort(thread, factory, network, | 266 StunPort* port = new StunPort(thread, factory, network, min_port, max_port, |
270 ip, min_port, max_port, | 267 username, password, servers, origin); |
271 username, password, servers, | |
272 origin); | |
273 if (!port->Init()) { | 268 if (!port->Init()) { |
274 delete port; | 269 delete port; |
275 port = NULL; | 270 port = NULL; |
276 } | 271 } |
277 return port; | 272 return port; |
278 } | 273 } |
279 | 274 |
280 virtual ~StunPort() {} | 275 virtual ~StunPort() {} |
281 | 276 |
282 virtual void PrepareAddress() { | 277 virtual void PrepareAddress() { |
283 SendStunBindingRequests(); | 278 SendStunBindingRequests(); |
284 } | 279 } |
285 | 280 |
286 protected: | 281 protected: |
287 StunPort(rtc::Thread* thread, | 282 StunPort(rtc::Thread* thread, |
288 rtc::PacketSocketFactory* factory, | 283 rtc::PacketSocketFactory* factory, |
289 rtc::Network* network, | 284 rtc::Network* network, |
290 const rtc::IPAddress& ip, | |
291 uint16_t min_port, | 285 uint16_t min_port, |
292 uint16_t max_port, | 286 uint16_t max_port, |
293 const std::string& username, | 287 const std::string& username, |
294 const std::string& password, | 288 const std::string& password, |
295 const ServerAddresses& servers, | 289 const ServerAddresses& servers, |
296 const std::string& origin) | 290 const std::string& origin) |
297 : UDPPort(thread, | 291 : UDPPort(thread, |
298 factory, | 292 factory, |
299 network, | 293 network, |
300 ip, | |
301 min_port, | 294 min_port, |
302 max_port, | 295 max_port, |
303 username, | 296 username, |
304 password, | 297 password, |
305 origin, | 298 origin, |
306 false) { | 299 false) { |
307 // UDPPort will set these to local udp, updating these to STUN. | 300 // UDPPort will set these to local udp, updating these to STUN. |
308 set_type(STUN_PORT_TYPE); | 301 set_type(STUN_PORT_TYPE); |
309 set_server_addresses(servers); | 302 set_server_addresses(servers); |
310 } | 303 } |
311 }; | 304 }; |
312 | 305 |
313 } // namespace cricket | 306 } // namespace cricket |
314 | 307 |
315 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ | 308 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ |
OLD | NEW |