| 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 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 VERIFY(request.AddAttribute(options_attr)); | 600 VERIFY(request.AddAttribute(options_attr)); |
| 601 } | 601 } |
| 602 | 602 |
| 603 StunByteStringAttribute* data_attr = | 603 StunByteStringAttribute* data_attr = |
| 604 StunAttribute::CreateByteString(STUN_ATTR_DATA); | 604 StunAttribute::CreateByteString(STUN_ATTR_DATA); |
| 605 data_attr->CopyBytes(data, size); | 605 data_attr->CopyBytes(data, size); |
| 606 VERIFY(request.AddAttribute(data_attr)); | 606 VERIFY(request.AddAttribute(data_attr)); |
| 607 | 607 |
| 608 // TODO: compute the HMAC. | 608 // TODO: compute the HMAC. |
| 609 | 609 |
| 610 rtc::ByteBuffer buf; | 610 rtc::ByteBufferWriter buf; |
| 611 request.Write(&buf); | 611 request.Write(&buf); |
| 612 | 612 |
| 613 return SendPacket(buf.Data(), buf.Length(), options); | 613 return SendPacket(buf.Data(), buf.Length(), options); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void RelayEntry::ScheduleKeepAlive() { | 616 void RelayEntry::ScheduleKeepAlive() { |
| 617 if (current_connection_) { | 617 if (current_connection_) { |
| 618 current_connection_->SendAllocateRequest(this, kKeepAliveDelay); | 618 current_connection_->SendAllocateRequest(this, kKeepAliveDelay); |
| 619 } | 619 } |
| 620 } | 620 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 // by the server, The actual remote address is the one we recorded. | 696 // by the server, The actual remote address is the one we recorded. |
| 697 if (!port_->HasMagicCookie(data, size)) { | 697 if (!port_->HasMagicCookie(data, size)) { |
| 698 if (locked_) { | 698 if (locked_) { |
| 699 port_->OnReadPacket(data, size, ext_addr_, PROTO_UDP, packet_time); | 699 port_->OnReadPacket(data, size, ext_addr_, PROTO_UDP, packet_time); |
| 700 } else { | 700 } else { |
| 701 LOG(WARNING) << "Dropping packet: entry not locked"; | 701 LOG(WARNING) << "Dropping packet: entry not locked"; |
| 702 } | 702 } |
| 703 return; | 703 return; |
| 704 } | 704 } |
| 705 | 705 |
| 706 rtc::ByteBuffer buf(data, size); | 706 rtc::ByteBufferReader buf(data, size); |
| 707 RelayMessage msg; | 707 RelayMessage msg; |
| 708 if (!msg.Read(&buf)) { | 708 if (!msg.Read(&buf)) { |
| 709 LOG(INFO) << "Incoming packet was not STUN"; | 709 LOG(INFO) << "Incoming packet was not STUN"; |
| 710 return; | 710 return; |
| 711 } | 711 } |
| 712 | 712 |
| 713 // The incoming packet should be a STUN ALLOCATE response, SEND response, or | 713 // The incoming packet should be a STUN ALLOCATE response, SEND response, or |
| 714 // DATA indication. | 714 // DATA indication. |
| 715 if (current_connection_->CheckResponse(&msg)) { | 715 if (current_connection_->CheckResponse(&msg)) { |
| 716 return; | 716 return; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 if (rtc::Time64() - start_time_ <= kRetryTimeout) | 837 if (rtc::Time64() - start_time_ <= kRetryTimeout) |
| 838 entry_->ScheduleKeepAlive(); | 838 entry_->ScheduleKeepAlive(); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void AllocateRequest::OnTimeout() { | 841 void AllocateRequest::OnTimeout() { |
| 842 LOG(INFO) << "Allocate request timed out"; | 842 LOG(INFO) << "Allocate request timed out"; |
| 843 entry_->HandleConnectFailure(connection_->socket()); | 843 entry_->HandleConnectFailure(connection_->socket()); |
| 844 } | 844 } |
| 845 | 845 |
| 846 } // namespace cricket | 846 } // namespace cricket |
| OLD | NEW |