Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 namespace cricket { | 23 namespace cricket { |
| 24 | 24 |
| 25 // TODO: Move these to a common place (used in relayport too) | 25 // TODO: Move these to a common place (used in relayport too) |
| 26 const int KEEPALIVE_DELAY = 10 * 1000; // 10 seconds - sort timeouts | 26 const int KEEPALIVE_DELAY = 10 * 1000; // 10 seconds - sort timeouts |
| 27 const int RETRY_TIMEOUT = 50 * 1000; // ICE says 50 secs | 27 const int RETRY_TIMEOUT = 50 * 1000; // ICE says 50 secs |
| 28 // Stop sending STUN binding requests after this amount of time | 28 // Stop sending STUN binding requests after this amount of time |
| 29 // (in milliseconds) because the connection binding requests should keep | 29 // (in milliseconds) because the connection binding requests should keep |
| 30 // the NAT binding alive. | 30 // the NAT binding alive. |
| 31 const int KEEP_ALIVE_TIMEOUT = 2 * 60 * 1000; // 2 minutes | 31 const int KEEP_ALIVE_TIMEOUT = 2 * 60 * 1000; // 2 minutes |
| 32 // This maximum deadline is used for low cost networks in order to keep the NAT | |
| 33 // binding alive on a backup connection. | |
| 34 const uint32_t MAX_KEEP_ALIVE_DEADLINE = 0xFFFFFFFF; | |
| 32 | 35 |
| 33 // Handles a binding request sent to the STUN server. | 36 // Handles a binding request sent to the STUN server. |
| 34 class StunBindingRequest : public StunRequest { | 37 class StunBindingRequest : public StunRequest { |
| 35 public: | 38 public: |
| 36 StunBindingRequest(UDPPort* port, | 39 StunBindingRequest(UDPPort* port, |
| 37 const rtc::SocketAddress& addr, | 40 const rtc::SocketAddress& addr, |
| 38 uint32_t deadline) | 41 uint32_t deadline) |
| 39 : port_(port), server_addr_(addr), deadline_(deadline) { | 42 : port_(port), server_addr_(addr), deadline_(deadline) { |
| 40 start_time_ = rtc::Time(); | 43 start_time_ = rtc::Time(); |
| 41 } | 44 } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 } | 393 } |
| 391 } | 394 } |
| 392 | 395 |
| 393 void UDPPort::SendStunBindingRequest(const rtc::SocketAddress& stun_addr) { | 396 void UDPPort::SendStunBindingRequest(const rtc::SocketAddress& stun_addr) { |
| 394 if (stun_addr.IsUnresolvedIP()) { | 397 if (stun_addr.IsUnresolvedIP()) { |
| 395 ResolveStunAddress(stun_addr); | 398 ResolveStunAddress(stun_addr); |
| 396 | 399 |
| 397 } else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) { | 400 } else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) { |
| 398 // Check if |server_addr_| is compatible with the port's ip. | 401 // Check if |server_addr_| is compatible with the port's ip. |
| 399 if (IsCompatibleAddress(stun_addr)) { | 402 if (IsCompatibleAddress(stun_addr)) { |
| 400 requests_.Send(new StunBindingRequest(this, stun_addr, | 403 uint32_t deadline = (network_cost() == 0) |
|
juberti2
2016/02/26 01:53:41
I don't like the |deadline| terminology - it's rea
honghaiz3
2016/02/26 18:46:57
Added comments.
Renamed it to keepalive_lifetime.
| |
| 401 rtc::Time() + KEEP_ALIVE_TIMEOUT)); | 404 ? MAX_KEEP_ALIVE_DEADLINE |
| 405 : rtc::Time() + KEEP_ALIVE_TIMEOUT; | |
| 406 requests_.Send(new StunBindingRequest(this, stun_addr, deadline)); | |
| 402 } else { | 407 } else { |
| 403 // Since we can't send stun messages to the server, we should mark this | 408 // Since we can't send stun messages to the server, we should mark this |
| 404 // port ready. | 409 // port ready. |
| 405 LOG(LS_WARNING) << "STUN server address is incompatible."; | 410 LOG(LS_WARNING) << "STUN server address is incompatible."; |
| 406 OnStunBindingOrResolveRequestFailed(stun_addr); | 411 OnStunBindingOrResolveRequestFailed(stun_addr); |
| 407 } | 412 } |
| 408 } | 413 } |
| 409 } | 414 } |
| 410 | 415 |
| 411 bool UDPPort::MaybeSetDefaultLocalAddress(rtc::SocketAddress* addr) const { | 416 bool UDPPort::MaybeSetDefaultLocalAddress(rtc::SocketAddress* addr) const { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 const std::vector<Candidate>& existing_candidates = Candidates(); | 510 const std::vector<Candidate>& existing_candidates = Candidates(); |
| 506 std::vector<Candidate>::const_iterator it = existing_candidates.begin(); | 511 std::vector<Candidate>::const_iterator it = existing_candidates.begin(); |
| 507 for (; it != existing_candidates.end(); ++it) { | 512 for (; it != existing_candidates.end(); ++it) { |
| 508 if (it->address() == addr) | 513 if (it->address() == addr) |
| 509 return true; | 514 return true; |
| 510 } | 515 } |
| 511 return false; | 516 return false; |
| 512 } | 517 } |
| 513 | 518 |
| 514 } // namespace cricket | 519 } // namespace cricket |
| OLD | NEW |