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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 LOG(LS_ERROR) << "Binding response missing mapped address."; | 58 LOG(LS_ERROR) << "Binding response missing mapped address."; |
59 } else if (addr_attr->family() != STUN_ADDRESS_IPV4 && | 59 } else if (addr_attr->family() != STUN_ADDRESS_IPV4 && |
60 addr_attr->family() != STUN_ADDRESS_IPV6) { | 60 addr_attr->family() != STUN_ADDRESS_IPV6) { |
61 LOG(LS_ERROR) << "Binding address has bad family"; | 61 LOG(LS_ERROR) << "Binding address has bad family"; |
62 } else { | 62 } else { |
63 rtc::SocketAddress addr(addr_attr->ipaddr(), addr_attr->port()); | 63 rtc::SocketAddress addr(addr_attr->ipaddr(), addr_attr->port()); |
64 port_->OnStunBindingRequestSucceeded(server_addr_, addr); | 64 port_->OnStunBindingRequestSucceeded(server_addr_, addr); |
65 } | 65 } |
66 | 66 |
67 // The keep-alive requests will be stopped after its lifetime has passed. | 67 // The keep-alive requests will be stopped after its lifetime has passed. |
68 if (WithinLifetime(rtc::Time64())) { | 68 if (WithinLifetime(rtc::TimeMillis())) { |
69 port_->requests_.SendDelayed( | 69 port_->requests_.SendDelayed( |
70 new StunBindingRequest(port_, server_addr_, start_time_, lifetime_), | 70 new StunBindingRequest(port_, server_addr_, start_time_, lifetime_), |
71 port_->stun_keepalive_delay()); | 71 port_->stun_keepalive_delay()); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 virtual void OnErrorResponse(StunMessage* response) override { | 75 virtual void OnErrorResponse(StunMessage* response) override { |
76 const StunErrorCodeAttribute* attr = response->GetErrorCode(); | 76 const StunErrorCodeAttribute* attr = response->GetErrorCode(); |
77 if (!attr) { | 77 if (!attr) { |
78 LOG(LS_ERROR) << "Bad allocate response error code"; | 78 LOG(LS_ERROR) << "Bad allocate response error code"; |
79 } else { | 79 } else { |
80 LOG(LS_ERROR) << "Binding error response:" | 80 LOG(LS_ERROR) << "Binding error response:" |
81 << " class=" << attr->eclass() | 81 << " class=" << attr->eclass() |
82 << " number=" << attr->number() << " reason='" | 82 << " number=" << attr->number() << " reason='" |
83 << attr->reason() << "'"; | 83 << attr->reason() << "'"; |
84 } | 84 } |
85 | 85 |
86 port_->OnStunBindingOrResolveRequestFailed(server_addr_); | 86 port_->OnStunBindingOrResolveRequestFailed(server_addr_); |
87 | 87 |
88 int64_t now = rtc::Time64(); | 88 int64_t now = rtc::TimeMillis(); |
89 if (WithinLifetime(now) && | 89 if (WithinLifetime(now) && |
90 rtc::TimeDiff64(now, start_time_) < RETRY_TIMEOUT) { | 90 rtc::TimeDiff64(now, start_time_) < RETRY_TIMEOUT) { |
91 port_->requests_.SendDelayed( | 91 port_->requests_.SendDelayed( |
92 new StunBindingRequest(port_, server_addr_, start_time_, lifetime_), | 92 new StunBindingRequest(port_, server_addr_, start_time_, lifetime_), |
93 port_->stun_keepalive_delay()); | 93 port_->stun_keepalive_delay()); |
94 } | 94 } |
95 } | 95 } |
96 virtual void OnTimeout() override { | 96 virtual void OnTimeout() override { |
97 LOG(LS_ERROR) << "Binding request timed out from " | 97 LOG(LS_ERROR) << "Binding request timed out from " |
98 << port_->GetLocalAddress().ToSensitiveString() << " (" | 98 << port_->GetLocalAddress().ToSensitiveString() << " (" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 void UDPPort::SendStunBindingRequest(const rtc::SocketAddress& stun_addr) { | 407 void UDPPort::SendStunBindingRequest(const rtc::SocketAddress& stun_addr) { |
408 if (stun_addr.IsUnresolvedIP()) { | 408 if (stun_addr.IsUnresolvedIP()) { |
409 ResolveStunAddress(stun_addr); | 409 ResolveStunAddress(stun_addr); |
410 | 410 |
411 } else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) { | 411 } else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) { |
412 // Check if |server_addr_| is compatible with the port's ip. | 412 // Check if |server_addr_| is compatible with the port's ip. |
413 if (IsCompatibleAddress(stun_addr)) { | 413 if (IsCompatibleAddress(stun_addr)) { |
414 requests_.Send(new StunBindingRequest(this, stun_addr, rtc::Time64(), | 414 requests_.Send(new StunBindingRequest(this, stun_addr, rtc::TimeMillis(), |
415 stun_keepalive_lifetime_)); | 415 stun_keepalive_lifetime_)); |
416 } else { | 416 } else { |
417 // Since we can't send stun messages to the server, we should mark this | 417 // Since we can't send stun messages to the server, we should mark this |
418 // port ready. | 418 // port ready. |
419 LOG(LS_WARNING) << "STUN server address is incompatible."; | 419 LOG(LS_WARNING) << "STUN server address is incompatible."; |
420 OnStunBindingOrResolveRequestFailed(stun_addr); | 420 OnStunBindingOrResolveRequestFailed(stun_addr); |
421 } | 421 } |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 const std::vector<Candidate>& existing_candidates = Candidates(); | 519 const std::vector<Candidate>& existing_candidates = Candidates(); |
520 std::vector<Candidate>::const_iterator it = existing_candidates.begin(); | 520 std::vector<Candidate>::const_iterator it = existing_candidates.begin(); |
521 for (; it != existing_candidates.end(); ++it) { | 521 for (; it != existing_candidates.end(); ++it) { |
522 if (it->address() == addr) | 522 if (it->address() == addr) |
523 return true; | 523 return true; |
524 } | 524 } |
525 return false; | 525 return false; |
526 } | 526 } |
527 | 527 |
528 } // namespace cricket | 528 } // namespace cricket |
OLD | NEW |