You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/03/14 00:36:49 UTC

[trafficserver] branch quic-latest updated: Create RETRY packet

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 c9845e0  Create RETRY packet
c9845e0 is described below

commit c9845e0ed9d68ad2dd6abecd40f0e609459aea37
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Mar 14 09:31:32 2018 +0900

    Create RETRY packet
---
 iocore/net/quic/QUICPacket.cc                  | 10 ++++++++++
 iocore/net/quic/QUICPacket.h                   |  2 ++
 iocore/net/quic/test/test_QUICPacketFactory.cc | 19 +++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index 659e826..35e8749 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -782,6 +782,16 @@ QUICPacketFactory::create_initial_packet(QUICConnectionId connection_id, QUICPac
   return this->_create_encrypted_packet(std::move(header), true);
 }
 
+// retransmittable? depends on stateless?
+QUICPacketUPtr
+QUICPacketFactory::create_retry_packet(QUICConnectionId connection_id, QUICPacketNumber base_packet_number, ats_unique_buf payload,
+                                       size_t len)
+{
+  QUICPacketHeaderUPtr header = QUICPacketHeader::build(QUICPacketType::RETRY, connection_id, this->_packet_number_generator.next(),
+                                                        base_packet_number, this->_version, std::move(payload), len);
+  return this->_create_encrypted_packet(std::move(header), false);
+}
+
 QUICPacketUPtr
 QUICPacketFactory::create_handshake_packet(QUICConnectionId connection_id, QUICPacketNumber base_packet_number,
                                            ats_unique_buf payload, size_t len, bool retransmittable)
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 6306955..c4b13cb 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -342,6 +342,8 @@ public:
   QUICPacketUPtr create_version_negotiation_packet(const QUICPacket *packet_sent_by_client, QUICPacketNumber base_packet_number);
   QUICPacketUPtr create_initial_packet(QUICConnectionId connection_id, QUICPacketNumber base_packet_number, QUICVersion version,
                                        ats_unique_buf payload, size_t len);
+  QUICPacketUPtr create_retry_packet(QUICConnectionId connection_id, QUICPacketNumber base_packet_number, ats_unique_buf payload,
+                                     size_t len);
   QUICPacketUPtr create_handshake_packet(QUICConnectionId connection_id, QUICPacketNumber base_packet_number,
                                          ats_unique_buf payload, size_t len, bool retransmittable);
   QUICPacketUPtr create_server_protected_packet(QUICConnectionId connection_id, QUICPacketNumber base_packet_number,
diff --git a/iocore/net/quic/test/test_QUICPacketFactory.cc b/iocore/net/quic/test/test_QUICPacketFactory.cc
index 4f84f2d..d90ba77 100644
--- a/iocore/net/quic/test/test_QUICPacketFactory.cc
+++ b/iocore/net/quic/test/test_QUICPacketFactory.cc
@@ -55,6 +55,25 @@ TEST_CASE("QUICPacketFactory_Create_VersionNegotiationPacket", "[quic]")
   CHECK(memcmp(packet->payload(), "\xff\x00\x00\x09", 4) == 0);
 }
 
+TEST_CASE("QUICPacketFactory_Create_Retry", "[quic]")
+{
+  QUICPacketFactory factory;
+  MockQUICHandshakeProtocol hs_protocol;
+  factory.set_hs_protocol(&hs_protocol);
+  factory.set_version(0x11223344);
+
+  uint8_t raw[]          = {0xaa, 0xbb, 0xcc, 0xdd};
+  ats_unique_buf payload = ats_unique_malloc(sizeof(raw));
+  memcpy(payload.get(), raw, sizeof(raw));
+
+  QUICPacketUPtr packet = factory.create_retry_packet(0x01020304, 0, std::move(payload), sizeof(raw));
+  CHECK(packet->type() == QUICPacketType::RETRY);
+  CHECK(packet->connection_id() == 0x01020304);
+  CHECK(memcmp(packet->payload(), raw, sizeof(raw)) == 0);
+  CHECK((packet->packet_number() & 0xFFFFFFFF80000000) == 0);
+  CHECK(packet->version() == 0x11223344);
+}
+
 TEST_CASE("QUICPacketFactory_Create_Handshake", "[quic]")
 {
   QUICPacketFactory factory;

-- 
To stop receiving notification emails like this one, please contact
masaori@apache.org.