diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 5d9f459411..ea7c6a2b9d 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -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', diff --git a/p2p/base/asyncstuntcpsocket_unittest.cc b/p2p/base/asyncstuntcpsocket_unittest.cc index 806b43b2db..c0f7fc0994 100644 --- a/p2p/base/asyncstuntcpsocket_unittest.cc +++ b/p2p/base/asyncstuntcpsocket_unittest.cc @@ -8,7 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include +#include #include "p2p/base/asyncstuntcpsocket.h" #include "rtc_base/asyncsocket.h" diff --git a/p2p/base/basicpacketsocketfactory.h b/p2p/base/basicpacketsocketfactory.h index 08f525e90a..29f82db13d 100644 --- a/p2p/base/basicpacketsocketfactory.h +++ b/p2p/base/basicpacketsocketfactory.h @@ -11,6 +11,8 @@ #ifndef P2P_BASE_BASICPACKETSOCKETFACTORY_H_ #define P2P_BASE_BASICPACKETSOCKETFACTORY_H_ +#include + #include "p2p/base/packetsocketfactory.h" namespace rtc { diff --git a/p2p/base/fakeicetransport.h b/p2p/base/fakeicetransport.h index 236288ab0e..f3a8313792 100644 --- a/p2p/base/fakeicetransport.h +++ b/p2p/base/fakeicetransport.h @@ -11,7 +11,9 @@ #ifndef P2P_BASE_FAKEICETRANSPORT_H_ #define P2P_BASE_FAKEICETRANSPORT_H_ +#include #include +#include #include "p2p/base/icetransportinternal.h" #include "rtc_base/asyncinvoker.h" diff --git a/p2p/base/packetsocketfactory.h b/p2p/base/packetsocketfactory.h index aff67cd237..c4a60eae76 100644 --- a/p2p/base/packetsocketfactory.h +++ b/p2p/base/packetsocketfactory.h @@ -11,6 +11,9 @@ #ifndef P2P_BASE_PACKETSOCKETFACTORY_H_ #define P2P_BASE_PACKETSOCKETFACTORY_H_ +#include +#include + #include "rtc_base/constructormagic.h" #include "rtc_base/proxyinfo.h" diff --git a/p2p/base/packettransportinterface.h b/p2p/base/packettransportinterface.h index f957ae6613..aa65ee0397 100644 --- a/p2p/base/packettransportinterface.h +++ b/p2p/base/packettransportinterface.h @@ -21,4 +21,4 @@ namespace rtc { typedef PacketTransportInternal PacketTransportInterface; } -#endif +#endif // P2P_BASE_PACKETTRANSPORTINTERFACE_H_ diff --git a/p2p/base/portallocator.cc b/p2p/base/portallocator.cc index a091325523..84c1df24da 100644 --- a/p2p/base/portallocator.cc +++ b/p2p/base/portallocator.cc @@ -9,6 +9,9 @@ */ #include "p2p/base/portallocator.h" + +#include + #include "rtc_base/checks.h" namespace cricket { diff --git a/p2p/base/portallocator.h b/p2p/base/portallocator.h index 1092910a49..25a6d48fa5 100644 --- a/p2p/base/portallocator.h +++ b/p2p/base/portallocator.h @@ -148,7 +148,7 @@ struct RelayCredentials { typedef std::vector 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, diff --git a/p2p/base/portinterface.h b/p2p/base/portinterface.h index ea2601cdd9..6b97fecace 100644 --- a/p2p/base/portinterface.h +++ b/p2p/base/portinterface.h @@ -12,6 +12,7 @@ #define P2P_BASE_PORTINTERFACE_H_ #include +#include #include "p2p/base/jseptransport.h" #include "rtc_base/asyncpacketsocket.h" diff --git a/p2p/base/relayport.cc b/p2p/base/relayport.cc index 411bfd4bef..045f0c3644 100644 --- a/p2p/base/relayport.cc +++ b/p2p/base/relayport.cc @@ -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. diff --git a/p2p/base/relayport_unittest.cc b/p2p/base/relayport_unittest.cc index 9747b4372d..274bab369f 100644 --- a/p2p/base/relayport_unittest.cc +++ b/p2p/base/relayport_unittest.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include #include "p2p/base/basicpacketsocketfactory.h" diff --git a/p2p/base/relayserver.cc b/p2p/base/relayserver.cc index bb788196ea..a147904467 100644 --- a/p2p/base/relayserver.cc +++ b/p2p/base/relayserver.cc @@ -15,6 +15,7 @@ #endif // WEBRTC_POSIX #include +#include #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(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); diff --git a/p2p/base/relayserver.h b/p2p/base/relayserver.h index 9dbf6686be..54ef1cb07e 100644 --- a/p2p/base/relayserver.h +++ b/p2p/base/relayserver.h @@ -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 diff --git a/p2p/base/relayserver_unittest.cc b/p2p/base/relayserver_unittest.cc index 0dddbd2a43..8024016669 100644 --- a/p2p/base/relayserver_unittest.cc +++ b/p2p/base/relayserver_unittest.cc @@ -10,6 +10,7 @@ #include #include +#include #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(strlen(msg2))); EXPECT_TRUE(ReceiveRaw1().empty()); } + +} // namespace cricket diff --git a/p2p/base/stun.cc b/p2p/base/stun.cc index 1e7cf16f27..cad33af264 100644 --- a/p2p/base/stun.cc +++ b/p2p/base/stun.cc @@ -13,6 +13,7 @@ #include #include +#include #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; } diff --git a/p2p/base/stun.h b/p2p/base/stun.h index 6ff07b5766..b576d3767d 100644 --- a/p2p/base/stun.h +++ b/p2p/base/stun.h @@ -14,6 +14,7 @@ // This file contains classes for dealing with the STUN protocol, as specified // in RFC 5389, and its descendants. +#include #include #include @@ -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 CreateAddress(uint16_t type); static std::unique_ptr 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 diff --git a/p2p/base/stun_unittest.cc b/p2p/base/stun_unittest.cc index 38f29bbff8..9d418c4a00 100644 --- a/p2p/base/stun_unittest.cc +++ b/p2p/base/stun_unittest.cc @@ -9,6 +9,7 @@ */ #include +#include #include "p2p/base/stun.h" #include "rtc_base/arraysize.h" diff --git a/p2p/base/stunport.cc b/p2p/base/stunport.cc index 1685351f22..d450d8e94d 100644 --- a/p2p/base/stunport.cc +++ b/p2p/base/stunport.cc @@ -10,6 +10,9 @@ #include "p2p/base/stunport.h" +#include +#include + #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(req); rtc::PacketOptions options(DefaultDscpValue()); diff --git a/p2p/base/stunport.h b/p2p/base/stunport.h index cc2e25ac0f..cf45d1df59 100644 --- a/p2p/base/stunport.h +++ b/p2p/base/stunport.h @@ -11,6 +11,7 @@ #ifndef P2P_BASE_STUNPORT_H_ #define P2P_BASE_STUNPORT_H_ +#include #include #include diff --git a/p2p/base/stunport_unittest.cc b/p2p/base/stunport_unittest.cc index 3df13e8a85..e9acdb11a2 100644 --- a/p2p/base/stunport_unittest.cc +++ b/p2p/base/stunport_unittest.cc @@ -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) { diff --git a/p2p/base/stunrequest.cc b/p2p/base/stunrequest.cc index 15ee24b77f..851bd70b89 100644 --- a/p2p/base/stunrequest.cc +++ b/p2p/base/stunrequest.cc @@ -12,6 +12,7 @@ #include #include +#include #include "rtc_base/checks.h" #include "rtc_base/helpers.h" diff --git a/p2p/base/stunrequest.h b/p2p/base/stunrequest.h index 7bb0466408..99173af9d1 100644 --- a/p2p/base/stunrequest.h +++ b/p2p/base/stunrequest.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 diff --git a/p2p/base/stunrequest_unittest.cc b/p2p/base/stunrequest_unittest.cc index bfcc046c67..f777b85f85 100644 --- a/p2p/base/stunrequest_unittest.cc +++ b/p2p/base/stunrequest_unittest.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #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 diff --git a/p2p/base/stunserver.cc b/p2p/base/stunserver.cc index 197c28c7e3..a9f0e99cd1 100644 --- a/p2p/base/stunserver.cc +++ b/p2p/base/stunserver.cc @@ -10,6 +10,8 @@ #include "p2p/base/stunserver.h" +#include + #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()) { diff --git a/p2p/base/stunserver_unittest.cc b/p2p/base/stunserver_unittest.cc index 5868058045..d1b65b2da3 100644 --- a/p2p/base/stunserver_unittest.cc +++ b/p2p/base/stunserver_unittest.cc @@ -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 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 diff --git a/p2p/base/tcpport.cc b/p2p/base/tcpport.cc index 85d2d8a8cb..f6caf3e8c5 100644 --- a/p2p/base/tcpport.cc +++ b/p2p/base/tcpport.cc @@ -66,6 +66,8 @@ #include "p2p/base/tcpport.h" +#include + #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; } diff --git a/p2p/base/tcpport.h b/p2p/base/tcpport.h index 11a8e2d14d..d20a8de1df 100644 --- a/p2p/base/tcpport.h +++ b/p2p/base/tcpport.h @@ -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_; diff --git a/p2p/base/tcpport_unittest.cc b/p2p/base/tcpport_unittest.cc index 7c426c0b93..12bb437517 100644 --- a/p2p/base/tcpport_unittest.cc +++ b/p2p/base/tcpport_unittest.cc @@ -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); } diff --git a/p2p/base/testrelayserver.h b/p2p/base/testrelayserver.h index 814929bb92..0d360cf248 100644 --- a/p2p/base/testrelayserver.h +++ b/p2p/base/testrelayserver.h @@ -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 tcp_int_socket_; diff --git a/p2p/base/testturncustomizer.h b/p2p/base/testturncustomizer.h index 012306f56c..d05569657c 100644 --- a/p2p/base/testturncustomizer.h +++ b/p2p/base/testturncustomizer.h @@ -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_) { diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc index 00fdbb2985..e67682430a 100644 --- a/p2p/base/turnport.cc +++ b/p2p/base/turnport.cc @@ -12,6 +12,8 @@ #include #include +#include +#include #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. diff --git a/p2p/base/turnport.h b/p2p/base/turnport.h index 3d34d46f1c..8246b43df6 100644 --- a/p2p/base/turnport.h +++ b/p2p/base/turnport.h @@ -13,8 +13,10 @@ #include #include +#include #include #include +#include #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. diff --git a/p2p/base/turnport_unittest.cc b/p2p/base/turnport_unittest.cc index 4abc02530f..0e9d1e2112 100644 --- a/p2p/base/turnport_unittest.cc +++ b/p2p/base/turnport_unittest.cc @@ -13,6 +13,8 @@ #include #include +#include +#include #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_)++; } diff --git a/p2p/base/turnserver.cc b/p2p/base/turnserver.cc index 6eedeafb33..902e889057 100644 --- a/p2p/base/turnserver.cc +++ b/p2p/base/turnserver.cc @@ -11,6 +11,7 @@ #include "p2p/base/turnserver.h" #include // for std::tie +#include #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()); diff --git a/p2p/base/turnserver.h b/p2p/base/turnserver.h index 89534846cc..3ead996c25 100644 --- a/p2p/base/turnserver.h +++ b/p2p/base/turnserver.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "p2p/base/portinterface.h" diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc index e161a864b0..b3b9e7347a 100644 --- a/p2p/client/basicportallocator.cc +++ b/p2p/client/basicportallocator.cc @@ -11,6 +11,7 @@ #include "p2p/client/basicportallocator.h" #include +#include #include #include diff --git a/p2p/client/basicportallocator_unittest.cc b/p2p/client/basicportallocator_unittest.cc index 78cc330988..a141328586 100644 --- a/p2p/client/basicportallocator_unittest.cc +++ b/p2p/client/basicportallocator_unittest.cc @@ -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)); diff --git a/p2p/client/socketmonitor.h b/p2p/client/socketmonitor.h index 1698a79b7a..6889803e04 100644 --- a/p2p/client/socketmonitor.h +++ b/p2p/client/socketmonitor.h @@ -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); diff --git a/p2p/stunprober/stunprober.cc b/p2p/stunprober/stunprober.cc index a302d47d8f..2a02cd02f1 100644 --- a/p2p/stunprober/stunprober.cc +++ b/p2p/stunprober/stunprober.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include "p2p/base/packetsocketfactory.h" #include "p2p/base/stun.h"