diff options
Diffstat (limited to 'chromium/third_party/libjingle/source/talk/p2p/base/relayport.cc')
-rw-r--r-- | chromium/third_party/libjingle/source/talk/p2p/base/relayport.cc | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/chromium/third_party/libjingle/source/talk/p2p/base/relayport.cc b/chromium/third_party/libjingle/source/talk/p2p/base/relayport.cc index ddfca7114ca..23571ea5fa7 100644 --- a/chromium/third_party/libjingle/source/talk/p2p/base/relayport.cc +++ b/chromium/third_party/libjingle/source/talk/p2p/base/relayport.cc @@ -67,7 +67,7 @@ class RelayConnection : public sigslot::has_slots<> { bool CheckResponse(StunMessage* msg); // Sends data to the relay server. - int Send(const void* pv, size_t cb, talk_base::DiffServCodePoint dscp); + int Send(const void* pv, size_t cb, const talk_base::PacketOptions& options); // Sends a STUN allocate request message to the relay server. void SendAllocateRequest(RelayEntry* entry, int delay); @@ -124,7 +124,7 @@ class RelayEntry : public talk_base::MessageHandler, // entry. This will wrap the packet in STUN if necessary. int SendTo(const void* data, size_t size, const talk_base::SocketAddress& addr, - talk_base::DiffServCodePoint dscp); + const talk_base::PacketOptions& options); // Schedules a keep-alive allocate request. void ScheduleKeepAlive(); @@ -166,7 +166,7 @@ class RelayEntry : public talk_base::MessageHandler, // Sends the given data on the socket to the server with no wrapping. This // returns the number of bytes written or -1 if an error occurred. int SendPacket(const void* data, size_t size, - talk_base::DiffServCodePoint dscp); + const talk_base::PacketOptions& options); }; // Handles an allocate request for a particular RelayEntry. @@ -240,8 +240,11 @@ void RelayPort::SetReady() { for (iter = external_addr_.begin(); iter != external_addr_.end(); ++iter) { std::string proto_name = ProtoToString(iter->proto); - AddAddress(iter->address, iter->address, proto_name, - RELAY_PORT_TYPE, ICE_TYPE_PREFERENCE_RELAY, false); + // In case of Gturn, related address is set to null socket address. + // This is due to as mapped address stun attribute is used for allocated + // address. + AddAddress(iter->address, iter->address, talk_base::SocketAddress(), + proto_name, RELAY_PORT_TYPE, ICE_TYPE_PREFERENCE_RELAY, false); } ready_ = true; SignalPortComplete(this); @@ -258,8 +261,9 @@ bool RelayPort::HasMagicCookie(const char* data, size_t size) { if (size < 24 + sizeof(TURN_MAGIC_COOKIE_VALUE)) { return false; } else { - return 0 == std::memcmp(data + 24, TURN_MAGIC_COOKIE_VALUE, - sizeof(TURN_MAGIC_COOKIE_VALUE)); + return memcmp(data + 24, + TURN_MAGIC_COOKIE_VALUE, + sizeof(TURN_MAGIC_COOKIE_VALUE)) == 0; } } @@ -304,7 +308,7 @@ Connection* RelayPort::CreateConnection(const Candidate& address, int RelayPort::SendTo(const void* data, size_t size, const talk_base::SocketAddress& addr, - talk_base::DiffServCodePoint dscp, + const talk_base::PacketOptions& options, bool payload) { // Try to find an entry for this specific address. Note that the first entry // created was not given an address initially, so it can be set to the first @@ -346,7 +350,7 @@ int RelayPort::SendTo(const void* data, size_t size, } // Send the actual contents to the server using the usual mechanism. - int sent = entry->SendTo(data, size, addr, dscp); + int sent = entry->SendTo(data, size, addr, options); if (sent <= 0) { ASSERT(sent < 0); error_ = entry->GetError(); @@ -359,14 +363,6 @@ int RelayPort::SendTo(const void* data, size_t size, int RelayPort::SetOption(talk_base::Socket::Option opt, int value) { int result = 0; - // DSCP option is not passed to the socket. - // TODO(mallinath) - After we have the support on socket, - // remove this specialization. - if (opt == talk_base::Socket::OPT_DSCP) { - SetDefaultDscpValue(static_cast<talk_base::DiffServCodePoint>(value)); - return result; - } - for (size_t i = 0; i < entries_.size(); ++i) { if (entries_[i]->SetSocketOption(opt, value) < 0) { result = -1; @@ -434,18 +430,18 @@ bool RelayConnection::CheckResponse(StunMessage* msg) { void RelayConnection::OnSendPacket(const void* data, size_t size, StunRequest* req) { // TODO(mallinath) Find a way to get DSCP value from Port. - int sent = socket_->SendTo( - data, size, GetAddress(), talk_base::DSCP_NO_CHANGE); + talk_base::PacketOptions options; // Default dscp set to NO_CHANGE. + int sent = socket_->SendTo(data, size, GetAddress(), options); if (sent <= 0) { LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress() << - std::strerror(socket_->GetError()); + strerror(socket_->GetError()); ASSERT(sent < 0); } } int RelayConnection::Send(const void* pv, size_t cb, - talk_base::DiffServCodePoint dscp) { - return socket_->SendTo(pv, cb, GetAddress(), dscp); + const talk_base::PacketOptions& options) { + return socket_->SendTo(pv, cb, GetAddress(), options); } void RelayConnection::SendAllocateRequest(RelayEntry* entry, int delay) { @@ -555,21 +551,17 @@ void RelayEntry::OnConnect(const talk_base::SocketAddress& mapped_addr, << " @ " << mapped_addr.ToSensitiveString(); connected_ = true; - // In case of Gturn related address is set to null socket address. - // This is due to mapped address stun attribute is used for allocated - // address. - port_->set_related_address(talk_base::SocketAddress()); port_->AddExternalAddress(ProtocolAddress(mapped_addr, proto)); port_->SetReady(); } int RelayEntry::SendTo(const void* data, size_t size, const talk_base::SocketAddress& addr, - talk_base::DiffServCodePoint dscp) { + const talk_base::PacketOptions& options) { // If this connection is locked to the address given, then we can send the // packet with no wrapper. if (locked_ && (ext_addr_ == addr)) - return SendPacket(data, size, dscp); + return SendPacket(data, size, options); // Otherwise, we must wrap the given data in a STUN SEND request so that we // can communicate the destination address to the server. @@ -617,7 +609,7 @@ int RelayEntry::SendTo(const void* data, size_t size, talk_base::ByteBuffer buf; request.Write(&buf); - return SendPacket(buf.Data(), buf.Length(), dscp); + return SendPacket(buf.Data(), buf.Length(), options); } void RelayEntry::ScheduleKeepAlive() { @@ -766,12 +758,12 @@ void RelayEntry::OnReadyToSend(talk_base::AsyncPacketSocket* socket) { } int RelayEntry::SendPacket(const void* data, size_t size, - talk_base::DiffServCodePoint dscp) { + const talk_base::PacketOptions& options) { int sent = 0; if (current_connection_) { // We are connected, no need to send packets anywere else than to // the current connection. - sent = current_connection_->Send(data, size, dscp); + sent = current_connection_->Send(data, size, options); } return sent; } |