Fix cpplint errors in p2p/
Bug: webrtc:5273 Change-Id: Ida3c2ca1bbb611026f34d7144db9ec24840bf7fb Reviewed-on: https://webrtc-review.googlesource.com/26444 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21133}
This commit is contained in:
@ -32,7 +32,11 @@ CPPLINT_BLACKLIST = [
|
||||
'modules/media_file',
|
||||
'modules/utility',
|
||||
'modules/video_capture',
|
||||
'p2p',
|
||||
'p2p/base/sessiondescription.cc',
|
||||
'p2p/base/session.cc',
|
||||
'p2p/base/session.h',
|
||||
'p2p/base/pseudotcp.cc',
|
||||
'p2p/base/pseudotcp.h',
|
||||
'rtc_base',
|
||||
'sdk/android/src/jni',
|
||||
'sdk/objc',
|
||||
|
@ -8,7 +8,9 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "p2p/base/asyncstuntcpsocket.h"
|
||||
#include "rtc_base/asyncsocket.h"
|
||||
|
@ -11,6 +11,8 @@
|
||||
#ifndef P2P_BASE_BASICPACKETSOCKETFACTORY_H_
|
||||
#define P2P_BASE_BASICPACKETSOCKETFACTORY_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "p2p/base/packetsocketfactory.h"
|
||||
|
||||
namespace rtc {
|
||||
|
@ -11,7 +11,9 @@
|
||||
#ifndef P2P_BASE_FAKEICETRANSPORT_H_
|
||||
#define P2P_BASE_FAKEICETRANSPORT_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "p2p/base/icetransportinternal.h"
|
||||
#include "rtc_base/asyncinvoker.h"
|
||||
|
@ -11,6 +11,9 @@
|
||||
#ifndef P2P_BASE_PACKETSOCKETFACTORY_H_
|
||||
#define P2P_BASE_PACKETSOCKETFACTORY_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/proxyinfo.h"
|
||||
|
||||
|
@ -21,4 +21,4 @@ namespace rtc {
|
||||
typedef PacketTransportInternal PacketTransportInterface;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // P2P_BASE_PACKETTRANSPORTINTERFACE_H_
|
||||
|
@ -9,6 +9,9 @@
|
||||
*/
|
||||
|
||||
#include "p2p/base/portallocator.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace cricket {
|
||||
|
@ -148,7 +148,7 @@ struct RelayCredentials {
|
||||
typedef std::vector<ProtocolAddress> PortList;
|
||||
// TODO(deadbeef): Rename to TurnServerConfig.
|
||||
struct RelayServerConfig {
|
||||
RelayServerConfig(RelayType type);
|
||||
explicit RelayServerConfig(RelayType type);
|
||||
RelayServerConfig(const rtc::SocketAddress& address,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define P2P_BASE_PORTINTERFACE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "p2p/base/jseptransport.h"
|
||||
#include "rtc_base/asyncpacketsocket.h"
|
||||
|
@ -198,7 +198,7 @@ RelayPort::RelayPort(rtc::Thread* thread,
|
||||
error_(0) {
|
||||
entries_.push_back(
|
||||
new RelayEntry(this, rtc::SocketAddress()));
|
||||
// TODO: set local preference value for TCP based candidates.
|
||||
// TODO(?): set local preference value for TCP based candidates.
|
||||
}
|
||||
|
||||
RelayPort::~RelayPort() {
|
||||
@ -609,7 +609,7 @@ int RelayEntry::SendTo(const void* data, size_t size,
|
||||
data_attr->CopyBytes(data, size);
|
||||
request.AddAttribute(std::move(data_attr));
|
||||
|
||||
// TODO: compute the HMAC.
|
||||
// TODO(?): compute the HMAC.
|
||||
|
||||
rtc::ByteBufferWriter buf;
|
||||
request.Write(&buf);
|
||||
@ -659,7 +659,7 @@ void RelayEntry::OnMessage(rtc::Message *pmsg) {
|
||||
// the next address, otherwise give this connection more time and
|
||||
// await the real timeout.
|
||||
//
|
||||
// TODO: Connect to servers in parallel to speed up connect time
|
||||
// TODO(?): Connect to servers in parallel to speed up connect time
|
||||
// and to avoid giving up too early.
|
||||
port_->SignalSoftTimeout(ra);
|
||||
HandleConnectFailure(current_connection_->socket());
|
||||
@ -688,7 +688,7 @@ void RelayEntry::OnReadPacket(
|
||||
const rtc::SocketAddress& remote_addr,
|
||||
const rtc::PacketTime& packet_time) {
|
||||
// RTC_DCHECK(remote_addr == port_->server_addr());
|
||||
// TODO: are we worried about this?
|
||||
// TODO(?): are we worried about this?
|
||||
|
||||
if (current_connection_ == NULL || socket != current_connection_->socket()) {
|
||||
// This packet comes from an unknown address.
|
||||
|
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "p2p/base/basicpacketsocketfactory.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#endif // WEBRTC_POSIX
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "rtc_base/asynctcpsocket.h"
|
||||
#include "rtc_base/checks.h"
|
||||
@ -80,7 +81,7 @@ void SendStunError(const StunMessage& msg, rtc::AsyncPacketSocket* socket,
|
||||
}
|
||||
|
||||
RelayServer::RelayServer(rtc::Thread* thread)
|
||||
: thread_(thread), log_bindings_(true) {
|
||||
: thread_(thread), random_(rtc::SystemTimeNanos()), log_bindings_(true) {
|
||||
}
|
||||
|
||||
RelayServer::~RelayServer() {
|
||||
@ -217,7 +218,7 @@ void RelayServer::OnInternalPacket(
|
||||
RelayServerConnection* ext_conn = int_conn->binding()->GetExternalConnection(
|
||||
int_conn->default_destination());
|
||||
if (ext_conn && ext_conn->locked()) {
|
||||
// TODO: Check the HMAC.
|
||||
// TODO(?): Check the HMAC.
|
||||
ext_conn->Send(bytes, size);
|
||||
} else {
|
||||
// This happens very often and is not an error.
|
||||
@ -237,7 +238,7 @@ void RelayServer::OnExternalPacket(
|
||||
// If this connection already exists, then forward the traffic.
|
||||
ConnectionMap::iterator piter = connections_.find(ap);
|
||||
if (piter != connections_.end()) {
|
||||
// TODO: Check the HMAC.
|
||||
// TODO(?): Check the HMAC.
|
||||
RelayServerConnection* ext_conn = piter->second;
|
||||
RelayServerConnection* int_conn =
|
||||
ext_conn->binding()->GetInternalConnection(
|
||||
@ -268,7 +269,7 @@ void RelayServer::OnExternalPacket(
|
||||
uint32_t length =
|
||||
std::min(static_cast<uint32_t>(username_attr->length()), USERNAME_LENGTH);
|
||||
std::string username(username_attr->bytes(), length);
|
||||
// TODO: Check the HMAC.
|
||||
// TODO(?): Check the HMAC.
|
||||
|
||||
// The binding should already be present.
|
||||
BindingMap::iterator biter = bindings_.find(username);
|
||||
@ -317,7 +318,7 @@ bool RelayServer::HandleStun(
|
||||
if (username)
|
||||
username->append(username_attr->bytes(), username_attr->length());
|
||||
|
||||
// TODO: Check for unknown attributes (<= 0x7fff)
|
||||
// TODO(?): Check for unknown attributes (<= 0x7fff)
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -343,7 +344,7 @@ void RelayServer::HandleStunAllocate(
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Check the HMAC.
|
||||
// TODO(?): Check the HMAC.
|
||||
|
||||
// Find or create the binding for this username.
|
||||
|
||||
@ -400,7 +401,7 @@ void RelayServer::HandleStun(
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Check the HMAC.
|
||||
// TODO(?): Check the HMAC.
|
||||
|
||||
// Send this request to the appropriate handler.
|
||||
if (request.type() == STUN_SEND_REQUEST)
|
||||
@ -427,7 +428,8 @@ void RelayServer::HandleStunAllocate(
|
||||
int_conn->binding()->magic_cookie().size());
|
||||
response.AddAttribute(std::move(magic_cookie_attr));
|
||||
|
||||
size_t index = rand() % external_sockets_.size();
|
||||
RTC_DCHECK_GT(external_sockets_.size(), 0);
|
||||
size_t index = random_.Rand(external_sockets_.size() - 1);
|
||||
rtc::SocketAddress ext_addr =
|
||||
external_sockets_[index]->GetLocalAddress();
|
||||
|
||||
@ -440,9 +442,9 @@ void RelayServer::HandleStunAllocate(
|
||||
res_lifetime_attr->SetValue(int_conn->binding()->lifetime() / 1000);
|
||||
response.AddAttribute(std::move(res_lifetime_attr));
|
||||
|
||||
// TODO: Support transport-prefs (preallocate RTCP port).
|
||||
// TODO: Support bandwidth restrictions.
|
||||
// TODO: Add message integrity check.
|
||||
// TODO(?): Support transport-prefs (preallocate RTCP port).
|
||||
// TODO(?): Support bandwidth restrictions.
|
||||
// TODO(?): Add message integrity check.
|
||||
|
||||
// Send a response to the caller.
|
||||
int_conn->SendStun(response);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "p2p/base/port.h"
|
||||
#include "p2p/base/stun.h"
|
||||
#include "rtc_base/asyncudpsocket.h"
|
||||
#include "rtc_base/random.h"
|
||||
#include "rtc_base/socketaddresspair.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
@ -76,6 +77,7 @@ class RelayServer : public rtc::MessageHandler,
|
||||
RelayServerConnection*> ConnectionMap;
|
||||
|
||||
rtc::Thread* thread_;
|
||||
webrtc::Random random_;
|
||||
bool log_bindings_;
|
||||
SocketList internal_sockets_;
|
||||
SocketList external_sockets_;
|
||||
@ -228,7 +230,7 @@ class RelayServerBinding : public rtc::MessageHandler {
|
||||
|
||||
int lifetime_;
|
||||
int64_t last_used_;
|
||||
// TODO: bandwidth
|
||||
// TODO(?): bandwidth
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "p2p/base/relayserver.h"
|
||||
#include "rtc_base/gunit.h"
|
||||
@ -23,18 +24,23 @@
|
||||
#include "rtc_base/virtualsocketserver.h"
|
||||
|
||||
using rtc::SocketAddress;
|
||||
using namespace cricket;
|
||||
|
||||
static const uint32_t LIFETIME = 4; // seconds
|
||||
static const SocketAddress server_int_addr("127.0.0.1", 5000);
|
||||
static const SocketAddress server_ext_addr("127.0.0.1", 5001);
|
||||
static const SocketAddress client1_addr("127.0.0.1", 6000 + (rand() % 1000));
|
||||
static const SocketAddress client2_addr("127.0.0.1", 7000 + (rand() % 1000));
|
||||
static const char* bad = "this is a completely nonsensical message whose only "
|
||||
"purpose is to make the parser go 'ack'. it doesn't "
|
||||
"look anything like a normal stun message";
|
||||
static const char* msg1 = "spamspamspamspamspamspamspambakedbeansspam";
|
||||
static const char* msg2 = "Lobster Thermidor a Crevette with a mornay sauce...";
|
||||
namespace cricket {
|
||||
namespace {
|
||||
|
||||
constexpr uint32_t LIFETIME = 4; // seconds
|
||||
const SocketAddress server_int_addr("127.0.0.1", 5000);
|
||||
const SocketAddress server_ext_addr("127.0.0.1", 5001);
|
||||
const SocketAddress client1_addr("127.0.0.1", 6111);
|
||||
const SocketAddress client2_addr("127.0.0.1", 7222);
|
||||
const char* bad =
|
||||
"this is a completely nonsensical message whose only "
|
||||
"purpose is to make the parser go 'ack'. it doesn't "
|
||||
"look anything like a normal stun message";
|
||||
const char* msg1 = "spamspamspamspamspamspamspambakedbeansspam";
|
||||
const char* msg2 = "Lobster Thermidor a Crevette with a mornay sauce...";
|
||||
|
||||
} // namespace
|
||||
|
||||
class RelayServerTest : public testing::Test {
|
||||
public:
|
||||
@ -511,3 +517,5 @@ TEST_F(RelayServerTest, DISABLED_TestExpiration) {
|
||||
SendRaw2(msg2, static_cast<int>(strlen(msg2)));
|
||||
EXPECT_TRUE(ReceiveRaw1().empty());
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "rtc_base/byteorder.h"
|
||||
#include "rtc_base/checks.h"
|
||||
@ -69,8 +70,7 @@ bool StunMessage::SetTransactionID(const std::string& str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ImplementationDefinedRange(int attr_type)
|
||||
{
|
||||
static bool ImplementationDefinedRange(int attr_type) {
|
||||
return attr_type >= 0xC000 && attr_type <= 0xFFFF;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
// This file contains classes for dealing with the STUN protocol, as specified
|
||||
// in RFC 5389, and its descendants.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -233,7 +234,7 @@ class StunAttribute {
|
||||
uint16_t type,
|
||||
uint16_t length,
|
||||
StunMessage* owner);
|
||||
// TODO: Allow these create functions to take parameters, to reduce
|
||||
// TODO(?): Allow these create functions to take parameters, to reduce
|
||||
// the amount of work callers need to do to initialize attributes.
|
||||
static std::unique_ptr<StunAddressAttribute> CreateAddress(uint16_t type);
|
||||
static std::unique_ptr<StunXorAddressAttribute> CreateXorAddress(
|
||||
@ -476,11 +477,11 @@ bool IsStunErrorResponseType(int msg_type);
|
||||
bool ComputeStunCredentialHash(const std::string& username,
|
||||
const std::string& realm, const std::string& password, std::string* hash);
|
||||
|
||||
// TODO: Move the TURN/ICE stuff below out to separate files.
|
||||
// TODO(?): Move the TURN/ICE stuff below out to separate files.
|
||||
extern const char TURN_MAGIC_COOKIE_VALUE[4];
|
||||
|
||||
// "GTURN" STUN methods.
|
||||
// TODO: Rename these methods to GTURN_ to make it clear they aren't
|
||||
// TODO(?): Rename these methods to GTURN_ to make it clear they aren't
|
||||
// part of standard STUN/TURN.
|
||||
enum RelayMessageType {
|
||||
// For now, using the same defs from TurnMessageType below.
|
||||
@ -494,7 +495,7 @@ enum RelayMessageType {
|
||||
};
|
||||
|
||||
// "GTURN"-specific STUN attributes.
|
||||
// TODO: Rename these attributes to GTURN_ to avoid conflicts.
|
||||
// TODO(?): Rename these attributes to GTURN_ to avoid conflicts.
|
||||
enum RelayAttributeType {
|
||||
STUN_ATTR_LIFETIME = 0x000d, // UInt32
|
||||
STUN_ATTR_MAGIC_COOKIE = 0x000f, // ByteString, 4 bytes
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "p2p/base/stun.h"
|
||||
#include "rtc_base/arraysize.h"
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "p2p/base/stunport.h"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "p2p/base/common.h"
|
||||
#include "p2p/base/portallocator.h"
|
||||
#include "p2p/base/stun.h"
|
||||
@ -21,7 +24,7 @@
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// TODO: Move these to a common place (used in relayport too)
|
||||
// TODO(?): Move these to a common place (used in relayport too)
|
||||
const int KEEPALIVE_DELAY = 10 * 1000; // 10 seconds - sort timeouts
|
||||
const int RETRY_TIMEOUT = 50 * 1000; // 50 seconds
|
||||
|
||||
@ -457,7 +460,6 @@ void UDPPort::OnStunBindingRequestSucceeded(
|
||||
// For STUN, related address is the local socket address.
|
||||
if ((!SharedSocket() || stun_reflected_addr != socket_->GetLocalAddress()) &&
|
||||
!HasCandidateWithAddress(stun_reflected_addr)) {
|
||||
|
||||
rtc::SocketAddress related_address = socket_->GetLocalAddress();
|
||||
// If we can't stamp the related address correctly, empty it to avoid leak.
|
||||
if (!MaybeSetDefaultLocalAddress(&related_address)) {
|
||||
@ -510,7 +512,7 @@ void UDPPort::MaybeSetPortCompleteOrError() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: merge this with SendTo above.
|
||||
// TODO(?): merge this with SendTo above.
|
||||
void UDPPort::OnSendPacket(const void* data, size_t size, StunRequest* req) {
|
||||
StunBindingRequest* sreq = static_cast<StunBindingRequest*>(req);
|
||||
rtc::PacketOptions options(DefaultDscpValue());
|
||||
|
@ -11,6 +11,7 @@
|
||||
#ifndef P2P_BASE_STUNPORT_H_
|
||||
#define P2P_BASE_STUNPORT_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -126,7 +126,6 @@ class StunPortTestBase : public testing::Test, public sigslot::has_slots<> {
|
||||
static void SetUpTestCase() {
|
||||
// Ensure the RNG is inited.
|
||||
rtc::InitRandom(NULL, 0);
|
||||
|
||||
}
|
||||
|
||||
void OnPortComplete(cricket::Port* port) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/helpers.h"
|
||||
|
@ -32,7 +32,7 @@ const int STUN_TOTAL_TIMEOUT = 39750; // milliseconds
|
||||
// response or determine that the request has timed out.
|
||||
class StunRequestManager {
|
||||
public:
|
||||
StunRequestManager(rtc::Thread* thread);
|
||||
explicit StunRequestManager(rtc::Thread* thread);
|
||||
~StunRequestManager();
|
||||
|
||||
// Starts sending the given request (perhaps after a delay).
|
||||
@ -83,7 +83,7 @@ class StunRequestManager {
|
||||
class StunRequest : public rtc::MessageHandler {
|
||||
public:
|
||||
StunRequest();
|
||||
StunRequest(StunMessage* request);
|
||||
explicit StunRequest(StunMessage* request);
|
||||
~StunRequest() override;
|
||||
|
||||
// Causes our wrapped StunMessage to be Prepared
|
||||
|
@ -8,6 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "p2p/base/stunrequest.h"
|
||||
#include "rtc_base/fakeclock.h"
|
||||
#include "rtc_base/gunit.h"
|
||||
@ -16,7 +18,7 @@
|
||||
#include "rtc_base/ssladapter.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
|
||||
using namespace cricket;
|
||||
namespace cricket {
|
||||
|
||||
class StunRequestTest : public testing::Test,
|
||||
public sigslot::has_slots<> {
|
||||
@ -198,3 +200,5 @@ TEST_F(StunRequestTest, TestNoEmptyRequest) {
|
||||
EXPECT_FALSE(timeout_);
|
||||
delete res;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "p2p/base/stunserver.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "rtc_base/bytebuffer.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
@ -34,8 +36,8 @@ void StunServer::OnPacket(
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: If unknown non-optional (<= 0x7fff) attributes are found, send a
|
||||
// 420 "Unknown Attribute" response.
|
||||
// TODO(?): If unknown non-optional (<= 0x7fff) attributes are found, send a
|
||||
// 420 "Unknown Attribute" response.
|
||||
|
||||
// Send the message to the appropriate handler function.
|
||||
switch (msg.type()) {
|
||||
|
@ -19,10 +19,12 @@
|
||||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/virtualsocketserver.h"
|
||||
|
||||
using namespace cricket;
|
||||
namespace cricket {
|
||||
|
||||
static const rtc::SocketAddress server_addr("99.99.99.1", 3478);
|
||||
static const rtc::SocketAddress client_addr("1.2.3.4", 1234);
|
||||
namespace {
|
||||
const rtc::SocketAddress server_addr("99.99.99.1", 3478);
|
||||
const rtc::SocketAddress client_addr("1.2.3.4", 1234);
|
||||
} // namespace
|
||||
|
||||
class StunServerTest : public testing::Test {
|
||||
public:
|
||||
@ -57,6 +59,7 @@ class StunServerTest : public testing::Test {
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<rtc::VirtualSocketServer> ss_;
|
||||
rtc::Thread network_;
|
||||
@ -93,7 +96,7 @@ TEST_F(StunServerTest, TestGood) {
|
||||
delete msg;
|
||||
}
|
||||
|
||||
#endif // if !defined(THREAD_SANITIZER)
|
||||
#endif // if !defined(THREAD_SANITIZER)
|
||||
|
||||
TEST_F(StunServerTest, TestBad) {
|
||||
const char* bad = "this is a completely nonsensical message whose only "
|
||||
@ -103,3 +106,5 @@ TEST_F(StunServerTest, TestBad) {
|
||||
|
||||
ASSERT_TRUE(ReceiveFails());
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -66,6 +66,8 @@
|
||||
|
||||
#include "p2p/base/tcpport.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "p2p/base/common.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
@ -370,7 +372,7 @@ int TCPConnection::Send(const void* data, size_t size,
|
||||
// Note that this is important to put this after the previous check to give
|
||||
// the connection a chance to reconnect.
|
||||
if (pretending_to_be_writable_ || write_state() != STATE_WRITABLE) {
|
||||
// TODO: Should STATE_WRITE_TIMEOUT return a non-blocking error?
|
||||
// TODO(?): Should STATE_WRITE_TIMEOUT return a non-blocking error?
|
||||
error_ = ENOTCONN;
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class TCPPort : public Port {
|
||||
void OnAddressReady(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SocketAddress& address);
|
||||
|
||||
// TODO: Is this still needed?
|
||||
// TODO(?): Is this still needed?
|
||||
bool incoming_only_;
|
||||
bool allow_listen_;
|
||||
rtc::AsyncPacketSocket* socket_;
|
||||
|
@ -31,7 +31,7 @@ static const SocketAddress kRemoteAddr("22.22.22.22", 0);
|
||||
|
||||
class ConnectionObserver : public sigslot::has_slots<> {
|
||||
public:
|
||||
ConnectionObserver(Connection* conn) {
|
||||
explicit ConnectionObserver(Connection* conn) {
|
||||
conn->SignalDestroyed.connect(this, &ConnectionObserver::OnDestroyed);
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ TEST_F(TCPPortTest, TCPPortNotDiscardedIfNotBoundToBestIP) {
|
||||
|
||||
class SentPacketCounter : public sigslot::has_slots<> {
|
||||
public:
|
||||
SentPacketCounter(TCPPort* p) {
|
||||
explicit SentPacketCounter(TCPPort* p) {
|
||||
p->SignalSentPacket.connect(this, &SentPacketCounter::OnSentPacket);
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,7 @@ class TestRelayServer : public sigslot::has_slots<> {
|
||||
void OnExternalClose(rtc::AsyncPacketSocket* socket, int error) {
|
||||
server_.RemoveExternalSocket(socket);
|
||||
}
|
||||
|
||||
private:
|
||||
cricket::RelayServer server_;
|
||||
std::unique_ptr<rtc::AsyncSocket> tcp_int_socket_;
|
||||
|
@ -30,7 +30,7 @@ class TestTurnCustomizer : public webrtc::TurnCustomizer {
|
||||
void MaybeModifyOutgoingStunMessage(
|
||||
cricket::PortInterface* port,
|
||||
cricket::StunMessage* message) override {
|
||||
modify_cnt_ ++;
|
||||
modify_cnt_++;
|
||||
|
||||
ASSERT_NE(0, message->type());
|
||||
if (add_counter_) {
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "p2p/base/common.h"
|
||||
@ -634,7 +636,6 @@ bool TurnPort::HandleIncomingPacket(rtc::AsyncPacketSocket* socket,
|
||||
if (IsTurnChannelData(msg_type)) {
|
||||
HandleChannelData(msg_type, data, size, packet_time);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (msg_type == TURN_DATA_INDICATION) {
|
||||
@ -1320,7 +1321,6 @@ void TurnAllocateRequest::OnAuthChallenge(StunMessage* response, int code) {
|
||||
}
|
||||
|
||||
void TurnAllocateRequest::OnTryAlternate(StunMessage* response, int code) {
|
||||
|
||||
// According to RFC 5389 section 11, there are use cases where
|
||||
// authentication of response is not possible, we're not validating
|
||||
// message integrity.
|
||||
|
@ -13,8 +13,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "p2p/base/port.h"
|
||||
#include "p2p/client/basicportallocator.h"
|
||||
@ -163,7 +165,7 @@ class TurnPort : public Port {
|
||||
SignalCreatePermissionResult;
|
||||
void FlushRequests(int msg_type) { request_manager_.Flush(msg_type); }
|
||||
bool HasRequests() { return !request_manager_.empty(); }
|
||||
void set_credentials(RelayCredentials& credentials) {
|
||||
void set_credentials(const RelayCredentials& credentials) {
|
||||
credentials_ = credentials;
|
||||
}
|
||||
// Finds the turn entry with |address| and sets its channel id.
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "p2p/base/basicpacketsocketfactory.h"
|
||||
#include "p2p/base/p2pconstants.h"
|
||||
@ -121,7 +123,7 @@ class TurnPortTestVirtualSocketServer : public rtc::VirtualSocketServer {
|
||||
|
||||
class TestConnectionWrapper : public sigslot::has_slots<> {
|
||||
public:
|
||||
TestConnectionWrapper(Connection* conn) : connection_(conn) {
|
||||
explicit TestConnectionWrapper(Connection* conn) : connection_(conn) {
|
||||
conn->SignalDestroyed.connect(
|
||||
this, &TestConnectionWrapper::OnConnectionDestroyed);
|
||||
}
|
||||
@ -1471,7 +1473,7 @@ class MessageObserver : public StunMessageObserver{
|
||||
channel_data_counter_(channel_data_counter),
|
||||
attr_counter_(attr_counter) {}
|
||||
virtual ~MessageObserver() {}
|
||||
virtual void ReceivedMessage(const TurnMessage* msg) override {
|
||||
void ReceivedMessage(const TurnMessage* msg) override {
|
||||
if (message_counter_ != nullptr) {
|
||||
(*message_counter_)++;
|
||||
}
|
||||
@ -1486,7 +1488,7 @@ class MessageObserver : public StunMessageObserver{
|
||||
}
|
||||
}
|
||||
|
||||
virtual void ReceivedChannelData(const char* data, size_t size) override {
|
||||
void ReceivedChannelData(const char* data, size_t size) override {
|
||||
if (channel_data_counter_ != nullptr) {
|
||||
(*channel_data_counter_)++;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "p2p/base/turnserver.h"
|
||||
|
||||
#include <tuple> // for std::tie
|
||||
#include <utility>
|
||||
|
||||
#include "p2p/base/asyncstuntcpsocket.h"
|
||||
#include "p2p/base/common.h"
|
||||
@ -30,7 +31,7 @@
|
||||
namespace cricket {
|
||||
|
||||
// TODO(juberti): Move this all to a future turnmessage.h
|
||||
//static const int IPPROTO_UDP = 17;
|
||||
// static const int IPPROTO_UDP = 17;
|
||||
static const int kNonceTimeout = 60 * 60 * 1000; // 60 minutes
|
||||
static const int kDefaultAllocationTimeout = 10 * 60 * 1000; // 10 minutes
|
||||
static const int kPermissionTimeout = 5 * 60 * 1000; // 5 minutes
|
||||
@ -196,7 +197,7 @@ void TurnServer::OnInternalPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::PacketTime& packet_time) {
|
||||
// Fail if the packet is too small to even contain a channel header.
|
||||
if (size < TURN_CHANNEL_HEADER_SIZE) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
InternalSocketMap::iterator iter = server_sockets_.find(socket);
|
||||
RTC_DCHECK(iter != server_sockets_.end());
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "p2p/base/portinterface.h"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "p2p/client/basicportallocator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -110,7 +110,7 @@ std::ostream& operator<<(std::ostream& os,
|
||||
}
|
||||
os << c.ToString();
|
||||
first = false;
|
||||
};
|
||||
}
|
||||
os << ']';
|
||||
return os;
|
||||
}
|
||||
@ -1239,7 +1239,7 @@ TEST_F(BasicPortAllocatorTest,
|
||||
// the srflx addresses.
|
||||
TEST_F(
|
||||
BasicPortAllocatorTest,
|
||||
TestDisableAdapterEnumerationWithoutNatLocalhostCandidateDisabledWithDifferentDefaultRoute) {
|
||||
TestDisableAdapterEnumerationWithoutNatLocalhostCandDisabledDiffRoute) {
|
||||
ResetWithStunServerNoNat(kStunAddr);
|
||||
AddInterfaceAsDefaultRoute(kClientAddr);
|
||||
EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
|
||||
|
@ -31,7 +31,7 @@ class ConnectionStatsGetter {
|
||||
|
||||
class ConnectionMonitor : public rtc::MessageHandler,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
public:
|
||||
ConnectionMonitor(ConnectionStatsGetter* stats_getter,
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* monitoring_thread);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "p2p/base/packetsocketfactory.h"
|
||||
#include "p2p/base/stun.h"
|
||||
|
Reference in New Issue
Block a user