trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From masa...@apache.org
Subject [trafficserver] branch quic-latest updated: Randomize initial value for packet number
Date Tue, 05 Sep 2017 07:33:36 GMT
This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
     new 913767a  Randomize initial value for packet number
913767a is described below

commit 913767ae488c7f2414545adc22bcc5fd003edba4
Author: Masaori Koshiba <masaori@apache.org>
AuthorDate: Tue Sep 5 16:32:32 2017 +0900

    Randomize initial value for packet number
---
 iocore/net/quic/QUICPacket.cc                  | 14 ++++++++++++++
 iocore/net/quic/QUICPacket.h                   |  3 ++-
 iocore/net/quic/test/test_QUICPacketFactory.cc |  2 +-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index 3ef847f..bfae22b 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -761,6 +761,20 @@ QUICPacketFactory::set_crypto_module(QUICCrypto *crypto)
 //
 // QUICPacketNumberGenerator
 //
+QUICPacketNumberGenerator::QUICPacketNumberGenerator()
+{
+  this->randomize();
+}
+
+QUICPacketNumber
+QUICPacketNumberGenerator::randomize()
+{
+  std::random_device rnd;
+  this->_current = rnd() & 0x7FFFFFFF;
+
+  return this->_current;
+}
+
 QUICPacketNumber
 QUICPacketNumberGenerator::next()
 {
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 326a348..147f13d 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -170,7 +170,8 @@ private:
 class QUICPacketNumberGenerator
 {
 public:
-  QUICPacketNumberGenerator(QUICPacketNumber initial_number = 0) : _current(initial_number){};
+  QUICPacketNumberGenerator();
+  QUICPacketNumber randomize();
   QUICPacketNumber next();
 
 private:
diff --git a/iocore/net/quic/test/test_QUICPacketFactory.cc b/iocore/net/quic/test/test_QUICPacketFactory.cc
index b92144b..ab989ae 100644
--- a/iocore/net/quic/test/test_QUICPacketFactory.cc
+++ b/iocore/net/quic/test/test_QUICPacketFactory.cc
@@ -65,6 +65,6 @@ TEST_CASE("QUICPacketFactory_Create_ServerCleartextPacket", "[quic]")
   CHECK(packet->type() == QUICPacketType::SERVER_CLEARTEXT);
   CHECK(packet->connection_id() == 0x01020304);
   CHECK(memcmp(packet->payload(), raw, sizeof(raw)) == 0);
-  CHECK(packet->packet_number() == 0);
+  CHECK((packet->packet_number() & 0xFFFFFFFF80000000) == 0);
   CHECK(packet->version() == 0x11223344);
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message