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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 } | 779 } |
780 } | 780 } |
781 | 781 |
782 void TurnPort::OnAllocateRequestTimeout() { | 782 void TurnPort::OnAllocateRequestTimeout() { |
783 OnAllocateError(); | 783 OnAllocateError(); |
784 } | 784 } |
785 | 785 |
786 void TurnPort::HandleDataIndication(const char* data, size_t size, | 786 void TurnPort::HandleDataIndication(const char* data, size_t size, |
787 const rtc::PacketTime& packet_time) { | 787 const rtc::PacketTime& packet_time) { |
788 // Read in the message, and process according to RFC5766, Section 10.4. | 788 // Read in the message, and process according to RFC5766, Section 10.4. |
789 rtc::ByteBuffer buf(data, size); | 789 rtc::ByteBufferReader buf(data, size); |
790 TurnMessage msg; | 790 TurnMessage msg; |
791 if (!msg.Read(&buf)) { | 791 if (!msg.Read(&buf)) { |
792 LOG_J(LS_WARNING, this) << "Received invalid TURN data indication"; | 792 LOG_J(LS_WARNING, this) << "Received invalid TURN data indication"; |
793 return; | 793 return; |
794 } | 794 } |
795 | 795 |
796 // Check mandatory attributes. | 796 // Check mandatory attributes. |
797 const StunAddressAttribute* addr_attr = | 797 const StunAddressAttribute* addr_attr = |
798 msg.GetAddress(STUN_ATTR_XOR_PEER_ADDRESS); | 798 msg.GetAddress(STUN_ATTR_XOR_PEER_ADDRESS); |
799 if (!addr_attr) { | 799 if (!addr_attr) { |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 delay); | 1418 delay); |
1419 } | 1419 } |
1420 | 1420 |
1421 void TurnEntry::SendChannelBindRequest(int delay) { | 1421 void TurnEntry::SendChannelBindRequest(int delay) { |
1422 port_->SendRequest(new TurnChannelBindRequest( | 1422 port_->SendRequest(new TurnChannelBindRequest( |
1423 port_, this, channel_id_, ext_addr_), delay); | 1423 port_, this, channel_id_, ext_addr_), delay); |
1424 } | 1424 } |
1425 | 1425 |
1426 int TurnEntry::Send(const void* data, size_t size, bool payload, | 1426 int TurnEntry::Send(const void* data, size_t size, bool payload, |
1427 const rtc::PacketOptions& options) { | 1427 const rtc::PacketOptions& options) { |
1428 rtc::ByteBuffer buf; | 1428 rtc::ByteBufferWriter buf; |
1429 if (state_ != STATE_BOUND) { | 1429 if (state_ != STATE_BOUND) { |
1430 // If we haven't bound the channel yet, we have to use a Send Indication. | 1430 // If we haven't bound the channel yet, we have to use a Send Indication. |
1431 TurnMessage msg; | 1431 TurnMessage msg; |
1432 msg.SetType(TURN_SEND_INDICATION); | 1432 msg.SetType(TURN_SEND_INDICATION); |
1433 msg.SetTransactionID( | 1433 msg.SetTransactionID( |
1434 rtc::CreateRandomString(kStunTransactionIdLength)); | 1434 rtc::CreateRandomString(kStunTransactionIdLength)); |
1435 VERIFY(msg.AddAttribute(new StunXorAddressAttribute( | 1435 VERIFY(msg.AddAttribute(new StunXorAddressAttribute( |
1436 STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_))); | 1436 STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_))); |
1437 VERIFY(msg.AddAttribute(new StunByteStringAttribute( | 1437 VERIFY(msg.AddAttribute(new StunByteStringAttribute( |
1438 STUN_ATTR_DATA, data, size))); | 1438 STUN_ATTR_DATA, data, size))); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 } else { | 1512 } else { |
1513 state_ = STATE_UNBOUND; | 1513 state_ = STATE_UNBOUND; |
1514 port_->DestroyConnection(ext_addr_); | 1514 port_->DestroyConnection(ext_addr_); |
1515 } | 1515 } |
1516 } | 1516 } |
1517 void TurnEntry::OnChannelBindTimeout() { | 1517 void TurnEntry::OnChannelBindTimeout() { |
1518 state_ = STATE_UNBOUND; | 1518 state_ = STATE_UNBOUND; |
1519 port_->DestroyConnection(ext_addr_); | 1519 port_->DestroyConnection(ext_addr_); |
1520 } | 1520 } |
1521 } // namespace cricket | 1521 } // namespace cricket |
OLD | NEW |