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 2017/11/17 06:56:49 UTC

[trafficserver] branch quic-latest updated: Make tests compilable

This is an automated email from the ASF dual-hosted git repository.

maskit 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 0e83437  Make tests compilable
0e83437 is described below

commit 0e83437af5abf82a64da3de326cd82114b8fd95e
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Fri Nov 17 15:54:42 2017 +0900

    Make tests compilable
---
 iocore/net/quic/QUICPacket.cc                  |  61 +++++---------
 iocore/net/quic/QUICPacket.h                   | 106 +++++++++++++++++++++----
 iocore/net/quic/test/Makefile.am               |  17 ++++
 iocore/net/quic/test/test_QUICCrypto.cc        |   4 +-
 iocore/net/quic/test/test_QUICKeyGenerator.cc  |  28 +++----
 iocore/net/quic/test/test_QUICPacket.cc        |  80 ++++++++-----------
 iocore/net/quic/test/test_QUICPacketFactory.cc |   9 ++-
 7 files changed, 177 insertions(+), 128 deletions(-)

diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index 82e0b74..2b5e87b 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -85,6 +85,12 @@ QUICPacketHeader::build(QUICPacketType type, QUICConnectionId connection_id, QUI
   return short_header;
 }
 
+QUICPacketHeader *
+QUICPacketHeader::clone() const
+{
+  return nullptr;
+}
+
 //
 // QUICPacketLongHeader
 //
@@ -451,12 +457,13 @@ QUICPacketShortHeader::store(uint8_t *buf, size_t *len) const
 //
 // QUICPacket
 //
-QUICPacket::QUICPacket(QUICPacketHeader *header, ats_unique_buf unprotected_payload, size_t unprotected_payload_len, QUICPacketNumber base_packet_number)
+
+QUICPacket::QUICPacket(QUICPacketHeader *header, ats_unique_buf payload, size_t payload_len, QUICPacketNumber base_packet_number)
 {
-  this->_size   = unprotected_payload_len;
-  this->_header = header;
-  this->_unprotected_payload     = std::move(unprotected_payload);
-  this->_unprotected_payload_len = unprotected_payload_len;
+  this->_header       = header;
+  this->_size         = this->_header->length() + payload_len;
+  this->_payload      = std::move(payload);
+  this->_payload_size = payload_len;
 }
 
 QUICPacket::QUICPacket(QUICPacketType type, QUICConnectionId connection_id, QUICPacketNumber packet_number,
@@ -546,10 +553,10 @@ QUICPacket::packet_number() const
   return this->_header->packet_number();
 }
 
-const uint8_t *
+const QUICPacketHeader *
 QUICPacket::header() const
 {
-  return this->_header->buf();
+  return this->_header;
 }
 
 const uint8_t *
@@ -604,37 +611,8 @@ QUICPacket::key_phase() const
 void
 QUICPacket::store(uint8_t *buf, size_t *len) const
 {
-  this->_header->store(buf, len);
-  ink_assert(this->size() >= *len);
-
-  if (this->type() == QUICPacketType::STATELESS_RESET) {
-    memcpy(buf + *len, this->payload(), this->payload_size());
-    *len += this->payload_size();
-  } else if (this->type() != QUICPacketType::ZERO_RTT_PROTECTED && this->type() != QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_0 &&
-             this->type() != QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_1) {
-    memcpy(buf + *len, this->payload(), this->payload_size());
-    *len += this->payload_size();
-
-    // fnv1a(buf, *len, buf + *len);
-    // *len += FNV1A_HASH_LEN;
-  } else {
-    ink_assert(this->_protected_payload);
-    memcpy(buf + *len, this->_protected_payload.get(), this->_protected_payload_size);
-    *len += this->_protected_payload_size;
-  }
-}
-
-void
-QUICPacket::store_header(uint8_t *buf, size_t *len) const
-{
-  this->_header->store(buf, len);
-}
-
-void
-QUICPacket::set_protected_payload(ats_unique_buf cipher_txt, size_t cipher_txt_len)
-{
-  this->_protected_payload      = std::move(cipher_txt);
-  this->_protected_payload_size = cipher_txt_len;
+  memcpy(buf + *len, this->payload(), this->payload_size());
+  *len = this->payload_size();
 }
 
 uint8_t
@@ -790,11 +768,14 @@ QUICPacketFactory::create_server_protected_packet(QUICConnectionId connection_id
   // TODO: do not dump header twice
   uint8_t ad[17] = {0};
   size_t ad_len  = 0;
-  packet->store_header(ad, &ad_len);
+  packet->header()->store(ad, &ad_len);
 
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, packet->payload(), packet->payload_size(),
                              packet->packet_number(), ad, ad_len, packet->key_phase())) {
-    packet->set_protected_payload(std::move(cipher_txt), cipher_txt_len);
+    QUICPacket *ep = quicPacketAllocator.alloc();
+    new (ep) QUICPacket(packet->header()->clone(), std::move(cipher_txt), cipher_txt_len, base_packet_number);
+    packet = QUICPacketUPtr(ep, &QUICPacketDeleter::delete_packet);
+
     Debug("quic_packet_factory", "Encrypt Packet, pkt_num: %" PRIu64 ", header_len: %zu payload: %zu", packet->packet_number(),
           ad_len, cipher_txt_len);
     return packet;
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 1874447..5a56349 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -45,28 +45,81 @@ public:
   virtual QUICConnectionId connection_id() const = 0;
   virtual QUICPacketNumber packet_number() const = 0;
   virtual QUICVersion version() const            = 0;
+
+  /*
+   * Returns a pointer for the payload
+   */
   virtual const uint8_t *payload() const         = 0;
+
+  /*
+   * Returns a payload size based on header length and buffer size that is specified to the constructo.
+   */
   uint16_t payload_size() const;
-  virtual QUICKeyPhase key_phase() const         = 0;
+
+  /*
+   * Returns a header size
+   */
   virtual uint16_t length() const                = 0;
+
+  /*
+   * Returns a key phase
+   */
+  virtual QUICKeyPhase key_phase() const         = 0;
+
+  /*
+   * Stores serialized header
+   *
+   * The serialized data doesn't contain a payload part even if it was created with a buffer that contains payload data.
+   */
   virtual void store(uint8_t *buf, size_t *len) const = 0;
+
+  QUICPacketHeader *clone() const;
+
+  virtual bool has_key_phase() const     = 0;
+  virtual bool has_connection_id() const = 0;
+  virtual bool has_version() const       = 0;
+
+  /***** STATIC members *****/
+
+  /*
+   * Load data from a buffer and create a QUICPacketHeader
+   *
+   * This creates either a QUICPacketShortHeader or a QUICPacketLongHeader.
+   */
   static QUICPacketHeader *load(const uint8_t *buf, size_t len, QUICPacketNumber base);
+
+
+  /*
+   * Build a QUICPacketHeader
+   *
+   * This creates a QUICPacketLongHeader.
+   */
   static QUICPacketHeader *build(QUICPacketType type, QUICConnectionId connection_id, QUICPacketNumber packet_number,
                                  QUICPacketNumber base_packet_number, QUICVersion version, ats_unique_buf payload, size_t len);
+
+  /*
+   * Build a QUICPacketHeader
+   *
+   * This creates a QUICPacketShortHeader that contains a ConnectionID.
+   */
   static QUICPacketHeader *build(QUICPacketType type, QUICPacketNumber packet_number, QUICPacketNumber base_packet_number,
                                  ats_unique_buf payload, size_t len);
+
+  /*
+   * Build a QUICPacketHeader
+   *
+   * This creates a QUICPacketShortHeader that doesn't contain a ConnectionID..
+   */
   static QUICPacketHeader *build(QUICPacketType type, QUICConnectionId connection_id, QUICPacketNumber packet_number,
                                  QUICPacketNumber base_packet_number, ats_unique_buf payload, size_t len);
-  static QUICPacketHeader *build(QUICPacketType, QUICConnectionId connection_id, QUICStatelessToken stateless_reset_token);
-  virtual bool has_key_phase() const     = 0;
-  virtual bool has_connection_id() const = 0;
-  virtual bool has_version() const       = 0;
 
 protected:
   QUICPacketHeader(){};
 
-  const uint8_t *_buf                  = nullptr;
-  size_t _buf_len = 0;
+  // These two are used only if the instance was created with a buffer
+  const uint8_t *_buf           = nullptr;
+  size_t _buf_len               = 0;
+
   ats_unique_buf _payload              = ats_unique_buf(nullptr, [](void *p) { ats_free(p); });
   QUICPacketType _type                 = QUICPacketType::UNINITIALIZED;
   QUICKeyPhase _key_phase              = QUICKeyPhase::CLEARTEXT;
@@ -131,30 +184,53 @@ class QUICPacket
 {
 public:
   QUICPacket(){};
-  QUICPacket(QUICPacketHeader *header, ats_unique_buf unprotected_payload, size_t unprotected_payload_len, QUICPacketNumber base_packet_number);
+
+  /*
+   * Creates a QUICPacket with a QUICPacketHeader and a buffer that contains payload
+   * 
+   * QUICPacket class doesn't care about whether the payload is protected (encrypted) or not.
+   */
+  QUICPacket(QUICPacketHeader *header, ats_unique_buf payload, size_t payload_len, QUICPacketNumber base_packet_number);
+
+  /*
+   * Creates a QUICPacket that has a Long Header
+   */
   QUICPacket(QUICPacketType type, QUICConnectionId connection_id, QUICPacketNumber packet_number,
              QUICPacketNumber base_packet_number, QUICVersion version, ats_unique_buf payload, size_t len, bool retransmittable);
+
+  /*
+   * Creates a QUICPacket that has a Short Header
+   */
   QUICPacket(QUICPacketType type, QUICPacketNumber packet_number, QUICPacketNumber base_packet_number, ats_unique_buf payload,
              size_t len, bool retransmittable);
+
+  /*
+   * Creates a QUICPacket that has a Short Header with a Connection ID
+   */
   QUICPacket(QUICPacketType type, QUICConnectionId connection_id, QUICPacketNumber packet_number,
              QUICPacketNumber base_packet_number, ats_unique_buf payload, size_t len, bool retransmittabl);
+
+  /*
+   * Creates a QUICpacket for stateless reset
+   */
   QUICPacket(QUICPacketType type, QUICConnectionId connection_id, QUICStatelessToken stateless_reset_token);
   ~QUICPacket();
 
-  void set_protected_payload(ats_unique_buf cipher_txt, size_t cipher_txt_len);
   QUICPacketType type() const;
   QUICConnectionId connection_id() const;
   QUICPacketNumber packet_number() const;
   QUICVersion version() const;
-  const uint8_t *header() const;
+  const QUICPacketHeader *header() const;
   const uint8_t *payload() const;
   bool is_retransmittable() const;
   uint16_t size() const;
   uint16_t header_size() const;
   uint16_t payload_size() const;
   void store(uint8_t *buf, size_t *len) const;
-  void store_header(uint8_t *buf, size_t *len) const;
   QUICKeyPhase key_phase() const;
+
+  /***** STATIC MEMBERS *****/
+
   static uint8_t calc_packet_number_len(QUICPacketNumber num, QUICPacketNumber base);
   static bool encode_packet_number(QUICPacketNumber &dst, QUICPacketNumber src, size_t len);
   static bool decode_packet_number(QUICPacketNumber &dst, QUICPacketNumber src, size_t len, QUICPacketNumber largest_acked);
@@ -162,12 +238,10 @@ public:
   LINK(QUICPacket, link);
 
 private:
-  ats_unique_buf _protected_payload = ats_unique_buf(nullptr, [](void *p) { ats_free(p); });
-  size_t _size                      = 0;
-  size_t _protected_payload_size    = 0;
-  ats_unique_buf _unprotected_payload = ats_unique_buf(nullptr, [](void *p) { ats_free(p); });
-  size_t _unprotected_payload_len = 0;
   QUICPacketHeader *_header;
+  ats_unique_buf _payload  = ats_unique_buf(nullptr, [](void *p) { ats_free(p); });
+  size_t _payload_size     = 0;
+  size_t _size             = 0;
   bool _is_retransmittable = false;
 };
 
diff --git a/iocore/net/quic/test/Makefile.am b/iocore/net/quic/test/Makefile.am
index f43d35d..f750fea 100644
--- a/iocore/net/quic/test/Makefile.am
+++ b/iocore/net/quic/test/Makefile.am
@@ -130,6 +130,8 @@ test_QUICFrame_SOURCES = \
   ../QUICGlobals.cc \
   ../QUICFrame.cc \
   ../QUICPacket.cc \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
   ../QUICTypes.cc \
@@ -180,6 +182,8 @@ test_QUICFrameDispatcher_SOURCES = \
   ../QUICDebugNames.cc \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../../SSLNextProtocolSet.cc
 
 test_QUICFrameDispatcher_LDADD = \
@@ -299,6 +303,8 @@ test_QUICTransportParameters_SOURCES = \
   ../QUICVersionNegotiator.cc \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../QUICStream.cc \
   ../QUICIncomingFrameBuffer.cc \
   ../QUICStreamState.cc \
@@ -361,9 +367,12 @@ test_QUICCrypto_LDADD = \
 test_QUICCrypto_SOURCES = \
   main.cc \
   test_QUICCrypto.cc \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
   ../QUICCrypto.h \
+  ../QUICTypes.cc \
   ../QUICGlobals.cc \
   ../../SSLNextProtocolSet.cc
 
@@ -423,6 +432,8 @@ test_QUICTypeUtil_SOURCES = \
   ../QUICDebugNames.cc \
   ../QUICFrame.cc \
   ../QUICPacket.cc \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
   ../QUICTypes.cc
@@ -456,6 +467,8 @@ test_QUICAckFrameCreator_SOURCES = \
   ../QUICStreamState.cc \
   ../QUICFlowController.cc \
   ../QUICDebugNames.cc \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
   ../../SSLNextProtocolSet.cc
@@ -485,6 +498,8 @@ test_QUICVersionNegotiator_SOURCES = \
   ../QUICGlobals.cc \
   ../QUICTypes.cc \
   ../QUICPacket.cc \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
   ../QUICApplication.cc \
@@ -531,6 +546,8 @@ test_QUICFlowController_SOURCES = \
   ../QUICDebugNames.cc \
   ../QUICTypes.cc \
   ../QUICPacket.cc \
+  ../QUICKeyGenerator.cc \
+  $(QUICKeyGenerator_impl) \
   ../QUICCrypto.cc \
   $(QUICCrypto_impl) \
   ../QUICFrame.cc
diff --git a/iocore/net/quic/test/test_QUICCrypto.cc b/iocore/net/quic/test/test_QUICCrypto.cc
index 2d2f471..a375308 100644
--- a/iocore/net/quic/test/test_QUICCrypto.cc
+++ b/iocore/net/quic/test/test_QUICCrypto.cc
@@ -149,8 +149,8 @@ TEST_CASE("QUICCrypto 1-RTT", "[quic]")
   std::cout << "Post Handshake Message" << std::endl;
   print_hex(post_handshake_msg, post_handshake_msg_len);
 
-  CHECK(client->setup_session());
-  CHECK(server->setup_session());
+  CHECK(client->initialize_key_materials(0x8394c8f03e515708));
+  CHECK(server->initialize_key_materials(0x8394c8f03e515708));
 
   // encrypt - decrypt
   uint8_t original[] = {
diff --git a/iocore/net/quic/test/test_QUICKeyGenerator.cc b/iocore/net/quic/test/test_QUICKeyGenerator.cc
index cdae44a2..d8d122d 100644
--- a/iocore/net/quic/test/test_QUICKeyGenerator.cc
+++ b/iocore/net/quic/test/test_QUICKeyGenerator.cc
@@ -66,17 +66,13 @@ TEST_CASE("QUICKeyGenerator", "[quic]")
       0x55, 0x44, 0x0d, 0x5f, 0xf7, 0x50, 0x3d, 0xe4,
       0x99, 0x7b, 0xfd, 0x6b
     };
-    uint8_t actual_client_key[128];
-    size_t actual_client_key_len = sizeof(actual_client_key);
-    uint8_t actual_client_iv[128];
-    size_t actual_client_iv_len = sizeof(actual_client_iv);
 
-    keygen.generate(cid, actual_client_key, &actual_client_key_len, actual_client_iv, &actual_client_iv_len);
+    std::unique_ptr<KeyMaterial> actual_km = keygen.generate(cid);
 
-    CHECK(actual_client_key_len == sizeof(expected_client_key));
-    CHECK(memcmp(actual_client_key, expected_client_key, sizeof(expected_client_key)) == 0);
-    CHECK(actual_client_iv_len == sizeof(expected_client_iv));
-    CHECK(memcmp(actual_client_iv, expected_client_iv, sizeof(expected_client_iv)) == 0);
+    CHECK(actual_km->key_len == sizeof(expected_client_key));
+    CHECK(memcmp(actual_km->key, expected_client_key, sizeof(expected_client_key)) == 0);
+    CHECK(actual_km->iv_len == sizeof(expected_client_iv));
+    CHECK(memcmp(actual_km->iv, expected_client_iv, sizeof(expected_client_iv)) == 0);
   }
 
   SECTION("SERVER Cleartext")
@@ -92,16 +88,12 @@ TEST_CASE("QUICKeyGenerator", "[quic]")
       0x57, 0x82, 0x3b, 0x85, 0x2c, 0x7e, 0xf9, 0xe3,
       0x80, 0x2b, 0x69, 0x0b
     };
-    uint8_t actual_server_key[128];
-    size_t actual_server_key_len = sizeof(actual_server_key);
-    uint8_t actual_server_iv[128];
-    size_t actual_server_iv_len = sizeof(actual_server_iv);
 
-    keygen.generate(cid, actual_server_key, &actual_server_key_len, actual_server_iv, &actual_server_iv_len);
+    std::unique_ptr<KeyMaterial> actual_km = keygen.generate(cid);
 
-    CHECK(actual_server_key_len == sizeof(expected_server_key));
-    CHECK(memcmp(actual_server_key, expected_server_key, sizeof(expected_server_key)) == 0);
-    CHECK(actual_server_iv_len == sizeof(expected_server_iv));
-    CHECK(memcmp(actual_server_iv, expected_server_iv, sizeof(expected_server_iv)) == 0);
+    CHECK(actual_km->key_len == sizeof(expected_server_key));
+    CHECK(memcmp(actual_km->key, expected_server_key, sizeof(expected_server_key)) == 0);
+    CHECK(actual_km->iv_len == sizeof(expected_server_iv));
+    CHECK(memcmp(actual_km->iv, expected_server_iv, sizeof(expected_server_iv)) == 0);
   }
 }
diff --git a/iocore/net/quic/test/test_QUICPacket.cc b/iocore/net/quic/test/test_QUICPacket.cc
index 8c2f2bf..46ddb62 100644
--- a/iocore/net/quic/test/test_QUICPacket.cc
+++ b/iocore/net/quic/test/test_QUICPacket.cc
@@ -25,56 +25,38 @@
 
 #include "quic/QUICPacket.h"
 
-TEST_CASE("Loading Long Header Packet", "[quic]")
+TEST_CASE("QUICPacketHeader", "[quic]")
 {
-  uint8_t raw[]          = {0x01, 0x02, 0x03, 0x04};
-  ats_unique_buf payload = ats_unique_malloc(sizeof(raw));
-  memcpy(payload.get(), raw, sizeof(raw));
-
-  // Cleartext packet with a long header
-  QUICPacket packet1(QUICPacketType::CLIENT_CLEARTEXT, 0xffddbb9977553311ULL, 0xffcc9966, 0, 0x00112233, std::move(payload),
-                     sizeof(raw), true);
-
-  uint8_t buf[65536];
-  size_t len;
-  packet1.store(buf, &len);
-
-  const QUICPacket packet2(ats_unique_buf(buf, [](void *p) { ats_free(p); }), len, 0);
-
-  CHECK(packet2.type() == QUICPacketType::CLIENT_CLEARTEXT);
-  CHECK(packet2.connection_id() == 0xffddbb9977553311ULL);
-  CHECK(packet2.packet_number() == 0xffcc9966);
-  CHECK(packet2.version() == 0x00112233);
-  CHECK(packet2.size() == 29);
-  CHECK(packet2.payload_size() == sizeof(raw));
-  CHECK(memcmp(packet2.payload(), raw, sizeof(raw)) == 0);
-}
-
-TEST_CASE("Loading Short Header Packet", "[quic]")
-{
-  uint8_t raw[]          = {0x01, 0x02, 0x03, 0x04};
-  ats_unique_buf payload = ats_unique_malloc(sizeof(raw));
-  memcpy(payload.get(), raw, sizeof(raw));
-
-  uint8_t protected_raw[]          = {0x04, 0x03, 0x02, 0x01, 0x00};
-  ats_unique_buf protected_payload = ats_unique_malloc(sizeof(protected_raw));
-  memcpy(protected_payload.get(), protected_raw, sizeof(protected_raw));
-
-  // Cleartext packet with a long header
-  QUICPacket packet1(QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_0, 0xffcc9966, 0, std::move(payload), sizeof(raw), true);
-  packet1.set_protected_payload(std::move(protected_payload), sizeof(protected_raw));
-
-  uint8_t buf[65536];
-  size_t len;
-  packet1.store(buf, &len);
-
-  const QUICPacket packet2(ats_unique_buf(buf, [](void *p) { ats_free(p); }), len, 0);
-
-  CHECK(packet2.type() == QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_0);
-  CHECK(packet2.packet_number() == 0xffcc9966);
-  CHECK(packet2.size() == 10);
-  CHECK(packet2.payload_size() == sizeof(protected_raw));
-  CHECK(memcmp(packet2.payload(), protected_raw, sizeof(protected_raw)) == 0);
+  SECTION("Long Header")
+  {
+    const uint8_t input[] = {
+      0x81, // Long header, Type
+      0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // Connection ID
+      0x12, 0x34, 0x56, 0x78, // Packet number
+      0x11, 0x22, 0x33, 0x44, // Version
+      0xff, 0xff, // Payload (dummy)
+    };
+
+    QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
+    CHECK(header->type() == QUICPacketType::VERSION_NEGOTIATION);
+    CHECK(header->connection_id() == 0x01020304050607);
+    CHECK(header->packet_number() == 0);
+    CHECK(header->version() == 0x11223344);
+  }
+
+  SECTION("Short Header")
+  {
+    const uint8_t input[] = {
+      0x41, // Short header, with Connection ID, KeyPhse 0, Type
+      0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // Connection ID
+      0x12, 0x34, 0x56, 0x78, // Packet number
+      0xff, 0xff, // Payload (dummy)
+    };
+
+    QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
+    CHECK(header->connection_id() == 0x01020304050607);
+    CHECK(header->packet_number() == 0);
+  }
 }
 
 TEST_CASE("Loading Unknown Packet", "[quic]")
diff --git a/iocore/net/quic/test/test_QUICPacketFactory.cc b/iocore/net/quic/test/test_QUICPacketFactory.cc
index 942b49c..06d12c9 100644
--- a/iocore/net/quic/test/test_QUICPacketFactory.cc
+++ b/iocore/net/quic/test/test_QUICPacketFactory.cc
@@ -29,16 +29,19 @@ TEST_CASE("QUICPacketFactory_Create_VersionNegotiationPacket", "[quic]")
 {
   QUICPacketFactory factory;
 
-  uint8_t client_initial_packet_data[] = {
+  uint8_t client_initial_packet_header[] = {
     0x82,                                           // Type
     0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // Connection id
     0x00, 0x00, 0x00, 0x00,                         // Packet number
     0xaa, 0xbb, 0xcc, 0xdd,                         // Version
+  };
+  uint8_t client_initial_packet_payload[] = {
     0x00                                            // Payload
   };
 
-  QUICPacket client_initial_packet(ats_unique_buf(client_initial_packet_data, [](void *p) { ats_free(p); }),
-                                   sizeof(client_initial_packet_data), 0);
+  QUICPacketHeader *header = QUICPacketHeader::load(client_initial_packet_header, sizeof(client_initial_packet_header), 0);
+  QUICPacket client_initial_packet(header, ats_unique_buf(client_initial_packet_payload, [](void *p) { ats_free(p); }),
+                                   sizeof(client_initial_packet_payload), 0);
 
   QUICPacketUPtr packet = factory.create_version_negotiation_packet(&client_initial_packet, 0);
   CHECK(packet->type() == QUICPacketType::VERSION_NEGOTIATION);

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