| 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 |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 900 |
| 901 static bool MatchesChannelId(TurnEntry* e, int id) { | 901 static bool MatchesChannelId(TurnEntry* e, int id) { |
| 902 return e->channel_id() == id; | 902 return e->channel_id() == id; |
| 903 } | 903 } |
| 904 TurnEntry* TurnPort::FindEntry(int channel_id) const { | 904 TurnEntry* TurnPort::FindEntry(int channel_id) const { |
| 905 EntryList::const_iterator it = std::find_if(entries_.begin(), entries_.end(), | 905 EntryList::const_iterator it = std::find_if(entries_.begin(), entries_.end(), |
| 906 std::bind2nd(std::ptr_fun(MatchesChannelId), channel_id)); | 906 std::bind2nd(std::ptr_fun(MatchesChannelId), channel_id)); |
| 907 return (it != entries_.end()) ? *it : NULL; | 907 return (it != entries_.end()) ? *it : NULL; |
| 908 } | 908 } |
| 909 | 909 |
| 910 bool TurnPort::EntryExists(TurnEntry* e) { |
| 911 auto it = std::find(entries_.begin(), entries_.end(), e); |
| 912 return it != entries_.end(); |
| 913 } |
| 914 |
| 910 void TurnPort::CreateOrRefreshEntry(const rtc::SocketAddress& addr) { | 915 void TurnPort::CreateOrRefreshEntry(const rtc::SocketAddress& addr) { |
| 911 TurnEntry* entry = FindEntry(addr); | 916 TurnEntry* entry = FindEntry(addr); |
| 912 if (entry == nullptr) { | 917 if (entry == nullptr) { |
| 913 entry = new TurnEntry(this, next_channel_number_++, addr); | 918 entry = new TurnEntry(this, next_channel_number_++, addr); |
| 914 entries_.push_back(entry); | 919 entries_.push_back(entry); |
| 915 } else { | 920 } else { |
| 916 // The channel binding request for the entry will be refreshed automatically | 921 // The channel binding request for the entry will be refreshed automatically |
| 917 // until the entry is destroyed. | 922 // until the entry is destroyed. |
| 918 CancelEntryDestruction(entry); | 923 CancelEntryDestruction(entry); |
| 919 } | 924 } |
| 920 } | 925 } |
| 921 | 926 |
| 922 void TurnPort::DestroyEntry(TurnEntry* entry) { | 927 void TurnPort::DestroyEntry(TurnEntry* entry) { |
| 923 ASSERT(entry != NULL); | 928 ASSERT(entry != NULL); |
| 924 entry->SignalDestroyed(entry); | 929 entry->SignalDestroyed(entry); |
| 925 entries_.remove(entry); | 930 entries_.remove(entry); |
| 926 delete entry; | 931 delete entry; |
| 927 } | 932 } |
| 928 | 933 |
| 929 void TurnPort::DestroyEntryIfNotCancelled(TurnEntry* entry, | 934 void TurnPort::DestroyEntryIfNotCancelled(TurnEntry* entry, |
| 930 uint32_t timestamp) { | 935 uint32_t timestamp) { |
| 936 if (!EntryExists(entry)) { |
| 937 return; |
| 938 } |
| 931 bool cancelled = timestamp != entry->destruction_timestamp(); | 939 bool cancelled = timestamp != entry->destruction_timestamp(); |
| 932 if (!cancelled) { | 940 if (!cancelled) { |
| 933 DestroyEntry(entry); | 941 DestroyEntry(entry); |
| 934 } | 942 } |
| 935 } | 943 } |
| 936 | 944 |
| 937 void TurnPort::OnConnectionDestroyed(Connection* conn) { | 945 void TurnPort::OnConnectionDestroyed(Connection* conn) { |
| 938 // Schedule an event to destroy TurnEntry for the connection, which is | 946 // Schedule an event to destroy TurnEntry for the connection, which is |
| 939 // already destroyed. | 947 // already destroyed. |
| 940 const rtc::SocketAddress& remote_address = conn->remote_candidate().address(); | 948 const rtc::SocketAddress& remote_address = conn->remote_candidate().address(); |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 // bind request as per http://tools.ietf.org/html/rfc5766#section-11.3 | 1421 // bind request as per http://tools.ietf.org/html/rfc5766#section-11.3 |
| 1414 if (code == STUN_ERROR_STALE_NONCE) { | 1422 if (code == STUN_ERROR_STALE_NONCE) { |
| 1415 if (port_->UpdateNonce(response)) { | 1423 if (port_->UpdateNonce(response)) { |
| 1416 // Send channel bind request with fresh nonce. | 1424 // Send channel bind request with fresh nonce. |
| 1417 SendChannelBindRequest(0); | 1425 SendChannelBindRequest(0); |
| 1418 } | 1426 } |
| 1419 } | 1427 } |
| 1420 } | 1428 } |
| 1421 | 1429 |
| 1422 } // namespace cricket | 1430 } // namespace cricket |
| OLD | NEW |