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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 rtc::SocketAddress addr = address; | 303 rtc::SocketAddress addr = address; |
304 if (addr.IsAnyIP() && emit_localhost_for_anyaddress_) { | 304 if (addr.IsAnyIP() && emit_localhost_for_anyaddress_) { |
305 addr.SetIP(rtc::GetLoopbackIP(addr.family())); | 305 addr.SetIP(rtc::GetLoopbackIP(addr.family())); |
306 } | 306 } |
307 | 307 |
308 AddAddress(addr, addr, rtc::SocketAddress(), UDP_PROTOCOL_NAME, "", "", | 308 AddAddress(addr, addr, rtc::SocketAddress(), UDP_PROTOCOL_NAME, "", "", |
309 LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST, 0, false); | 309 LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST, 0, false); |
310 MaybePrepareStunCandidate(); | 310 MaybePrepareStunCandidate(); |
311 } | 311 } |
312 | 312 |
313 void UDPPort::OnReadPacket( | 313 void UDPPort::OnReadPacket(rtc::AsyncPacketSocket* socket, |
314 rtc::AsyncPacketSocket* socket, const char* data, size_t size, | 314 const char* data, |
315 const rtc::SocketAddress& remote_addr, | 315 size_t size, |
316 const rtc::PacketTime& packet_time) { | 316 const rtc::SocketAddress& remote_addr, |
| 317 const rtc::PacketTime& packet_time) { |
317 ASSERT(socket == socket_); | 318 ASSERT(socket == socket_); |
318 ASSERT(!remote_addr.IsUnresolved()); | 319 ASSERT(!remote_addr.IsUnresolvedIP()); |
319 | 320 |
320 // Look for a response from the STUN server. | 321 // Look for a response from the STUN server. |
321 // Even if the response doesn't match one of our outstanding requests, we | 322 // Even if the response doesn't match one of our outstanding requests, we |
322 // will eat it because it might be a response to a retransmitted packet, and | 323 // will eat it because it might be a response to a retransmitted packet, and |
323 // we already cleared the request when we got the first response. | 324 // we already cleared the request when we got the first response. |
324 if (server_addresses_.find(remote_addr) != server_addresses_.end()) { | 325 if (server_addresses_.find(remote_addr) != server_addresses_.end()) { |
325 requests_.CheckResponse(data, size); | 326 requests_.CheckResponse(data, size); |
326 return; | 327 return; |
327 } | 328 } |
328 | 329 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 377 } |
377 | 378 |
378 server_addresses_.erase(input); | 379 server_addresses_.erase(input); |
379 | 380 |
380 if (server_addresses_.find(resolved) == server_addresses_.end()) { | 381 if (server_addresses_.find(resolved) == server_addresses_.end()) { |
381 server_addresses_.insert(resolved); | 382 server_addresses_.insert(resolved); |
382 SendStunBindingRequest(resolved); | 383 SendStunBindingRequest(resolved); |
383 } | 384 } |
384 } | 385 } |
385 | 386 |
386 void UDPPort::SendStunBindingRequest( | 387 void UDPPort::SendStunBindingRequest(const rtc::SocketAddress& stun_addr) { |
387 const rtc::SocketAddress& stun_addr) { | 388 if (stun_addr.IsUnresolvedIP()) { |
388 if (stun_addr.IsUnresolved()) { | |
389 ResolveStunAddress(stun_addr); | 389 ResolveStunAddress(stun_addr); |
390 | 390 |
391 } else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) { | 391 } else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) { |
392 // Check if |server_addr_| is compatible with the port's ip. | 392 // Check if |server_addr_| is compatible with the port's ip. |
393 if (IsCompatibleAddress(stun_addr)) { | 393 if (IsCompatibleAddress(stun_addr)) { |
394 requests_.Send(new StunBindingRequest(this, true, stun_addr)); | 394 requests_.Send(new StunBindingRequest(this, true, stun_addr)); |
395 } else { | 395 } else { |
396 // Since we can't send stun messages to the server, we should mark this | 396 // Since we can't send stun messages to the server, we should mark this |
397 // port ready. | 397 // port ready. |
398 LOG(LS_WARNING) << "STUN server address is incompatible."; | 398 LOG(LS_WARNING) << "STUN server address is incompatible."; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 const std::vector<Candidate>& existing_candidates = Candidates(); | 479 const std::vector<Candidate>& existing_candidates = Candidates(); |
480 std::vector<Candidate>::const_iterator it = existing_candidates.begin(); | 480 std::vector<Candidate>::const_iterator it = existing_candidates.begin(); |
481 for (; it != existing_candidates.end(); ++it) { | 481 for (; it != existing_candidates.end(); ++it) { |
482 if (it->address() == addr) | 482 if (it->address() == addr) |
483 return true; | 483 return true; |
484 } | 484 } |
485 return false; | 485 return false; |
486 } | 486 } |
487 | 487 |
488 } // namespace cricket | 488 } // namespace cricket |
OLD | NEW |