From 6d0d4bf31de1e36cab276ec3db994a952ba4b612 Mon Sep 17 00:00:00 2001 From: zhihuang Date: Tue, 24 May 2016 10:13:32 -0700 Subject: [PATCH] Change the size of the ICE ufrag to 4 bytes. This is the minumum allowed size, and will allow STUN pings to be smaller. The unit tests on the the Gturn are also modified. A username with length of 16 bytes will be generated for Gturn only. Review-Url: https://codereview.webrtc.org/1848083002 Cr-Commit-Position: refs/heads/master@{#12876} --- webrtc/p2p/base/p2pconstants.cc | 5 ++--- webrtc/p2p/base/p2ptransportchannel_unittest.cc | 4 ++-- webrtc/p2p/base/port_unittest.cc | 9 ++++++--- webrtc/p2p/base/portallocator_unittest.cc | 2 +- webrtc/p2p/client/basicportallocator_unittest.cc | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/webrtc/p2p/base/p2pconstants.cc b/webrtc/p2p/base/p2pconstants.cc index fd75984a08..64e5a13cf8 100644 --- a/webrtc/p2p/base/p2pconstants.cc +++ b/webrtc/p2p/base/p2pconstants.cc @@ -21,9 +21,8 @@ const char CN_OTHER[] = "main"; const char GROUP_TYPE_BUNDLE[] = "BUNDLE"; -// Minimum ufrag length is 4 characters as per RFC5245. We chose 16 because -// some internal systems expect username to be 16 bytes. -const int ICE_UFRAG_LENGTH = 16; +// Minimum ufrag length is 4 characters as per RFC5245. +const int ICE_UFRAG_LENGTH = 4; // Minimum password length of 22 characters as per RFC5245. We chose 24 because // some internal systems expect password to be multiple of 4. const int ICE_PWD_LENGTH = 24; diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index 54ab3196cb..d645c57894 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc @@ -90,8 +90,8 @@ static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0); static const cricket::RelayCredentials kRelayCredentials("test", "test"); // Based on ICE_UFRAG_LENGTH -static const char* kIceUfrag[4] = {"TESTICEUFRAG0000", "TESTICEUFRAG0001", - "TESTICEUFRAG0002", "TESTICEUFRAG0003"}; +static const char* kIceUfrag[4] = {"UF00", "UF01", + "UF02", "UF03"}; // Based on ICE_PWD_LENGTH static const char* kIcePwd[4] = {"TESTICEPWD00000000000000", "TESTICEPWD00000000000001", diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc index a5cbd92a7b..43ef084b02 100644 --- a/webrtc/p2p/base/port_unittest.cc +++ b/webrtc/p2p/base/port_unittest.cc @@ -76,6 +76,8 @@ static const int kTiebreaker2 = 22222; static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; +static const int kGturnUserNameLength = 16; + static Candidate GetCandidate(Port* port) { assert(port->Candidates().size() >= 1); return port->Candidates()[0]; @@ -525,9 +527,10 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { } RelayPort* CreateGturnPort(const SocketAddress& addr) { // TODO(pthatcher): Remove GTURN. - return RelayPort::Create(main_, &socket_factory_, &network_, - addr.ipaddr(), 0, 0, - username_, password_); + // Generate a username with length of 16 for Gturn only. + std::string username = rtc::CreateRandomString(kGturnUserNameLength); + return RelayPort::Create(main_, &socket_factory_, &network_, addr.ipaddr(), + 0, 0, username, password_); // TODO: Add an external address for ext_proto, so that the // other side can connect to this port using a non-UDP protocol. } diff --git a/webrtc/p2p/base/portallocator_unittest.cc b/webrtc/p2p/base/portallocator_unittest.cc index dd845236c4..6a34a25c13 100644 --- a/webrtc/p2p/base/portallocator_unittest.cc +++ b/webrtc/p2p/base/portallocator_unittest.cc @@ -18,7 +18,7 @@ static const char kSessionId[] = "session id"; static const char kContentName[] = "test content"; // Based on ICE_UFRAG_LENGTH -static const char kIceUfrag[] = "TESTICEUFRAG0000"; +static const char kIceUfrag[] = "UF00"; // Based on ICE_PWD_LENGTH static const char kIcePwd[] = "TESTICEPWD00000000000000"; static const char kTurnUsername[] = "test"; diff --git a/webrtc/p2p/client/basicportallocator_unittest.cc b/webrtc/p2p/client/basicportallocator_unittest.cc index 024f46fffc..6cd40ea9bd 100644 --- a/webrtc/p2p/client/basicportallocator_unittest.cc +++ b/webrtc/p2p/client/basicportallocator_unittest.cc @@ -64,7 +64,7 @@ static const int kMinPort = 10000; static const int kMaxPort = 10099; // Based on ICE_UFRAG_LENGTH -static const char kIceUfrag0[] = "TESTICEUFRAG0000"; +static const char kIceUfrag0[] = "UF00"; // Based on ICE_PWD_LENGTH static const char kIcePwd0[] = "TESTICEPWD00000000000000";