trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From masa...@apache.org
Subject [trafficserver] 02/02: Fix QUICTransportParameter
Date Tue, 22 Aug 2017 23:46:39 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

commit f98e16d6606509782ddb11dcf25797404aaccebd
Author: Masaori Koshiba <masaori@apache.org>
AuthorDate: Wed Aug 23 08:40:53 2017 +0900

    Fix QUICTransportParameter
    
    - Make data of QUICTransportParameterValue std::unique_ptr
    - Change _parameters table to std::map
    - Fix binary format of TransportParameter
---
 iocore/net/QUICNetVConnection.cc                   |  31 ++++-
 iocore/net/quic/QUICTransportParameters.cc         | 113 +++++++++++-------
 iocore/net/quic/QUICTransportParameters.h          |  22 ++--
 .../net/quic/test/test_QUICTransportParameters.cc  | 132 ++++++++++++++-------
 4 files changed, 195 insertions(+), 103 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 926c1d2..7ae5251 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -104,10 +104,33 @@ QUICNetVConnection::start(SSL_CTX *ssl_ctx)
   // FIXME Fill appropriate values
   // MUSTs
   QUICTransportParametersInEncryptedExtensions *tp = new QUICTransportParametersInEncryptedExtensions();
-  tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA, {reinterpret_cast<const
uint8_t *>("\x00\x00\x00\x00"), 4});
-  tp->add(QUICTransportParameterId::INITIAL_MAX_DATA, {reinterpret_cast<const uint8_t
*>("\x00\x00\x00\x00"), 4});
-  tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_ID, {reinterpret_cast<const
uint8_t *>("\x00\x00\x00\x00"), 4});
-  tp->add(QUICTransportParameterId::IDLE_TIMEOUT, {reinterpret_cast<const uint8_t *>("\x00\x00"),
2});
+
+  size_t max_stream_data_buf_len     = 4;
+  ats_unique_buf max_stream_data_buf = ats_unique_malloc(max_stream_data_buf_len);
+  memcpy(max_stream_data_buf.get(), "\x00\x00\x00\x00", max_stream_data_buf_len);
+  tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA,
+          std::unique_ptr<QUICTransportParameterValue>(
+            new QUICTransportParameterValue(std::move(max_stream_data_buf), max_stream_data_buf_len)));
+
+  size_t max_data_buf_len     = 4;
+  ats_unique_buf max_data_buf = ats_unique_malloc(max_data_buf_len);
+  memcpy(max_data_buf.get(), "\x00\x00\x00\x00", max_data_buf_len);
+  tp->add(QUICTransportParameterId::INITIAL_MAX_DATA,
+          std::unique_ptr<QUICTransportParameterValue>(new QUICTransportParameterValue(std::move(max_data_buf),
max_data_buf_len)));
+
+  uint16_t max_stream_id_buf_len   = 4;
+  ats_unique_buf max_stream_id_buf = ats_unique_malloc(max_stream_id_buf_len);
+  memcpy(max_stream_id_buf.get(), "\x00\x00\x00\x00", max_stream_id_buf_len);
+  tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_ID,
+          std::unique_ptr<QUICTransportParameterValue>(
+            new QUICTransportParameterValue(std::move(max_stream_id_buf), max_stream_id_buf_len)));
+
+  uint16_t idle_timeout_buf_len   = 2;
+  ats_unique_buf idle_timeout_buf = ats_unique_malloc(idle_timeout_buf_len);
+  memcpy(idle_timeout_buf.get(), "\x00\x00", idle_timeout_buf_len);
+  tp->add(QUICTransportParameterId::IDLE_TIMEOUT, std::unique_ptr<QUICTransportParameterValue>(new
QUICTransportParameterValue(
+                                                    std::move(idle_timeout_buf), idle_timeout_buf_len)));
+
   tp->add_version(QUIC_SUPPORTED_VERSIONS[0]);
   // MAYs
   // this->_local_transport_parameters.add(QUICTransportParameterId::TRUNCATE_CONNECTION_ID,
{});
diff --git a/iocore/net/quic/QUICTransportParameters.cc b/iocore/net/quic/QUICTransportParameters.cc
index fe0d0d8..c8638c4 100644
--- a/iocore/net/quic/QUICTransportParameters.cc
+++ b/iocore/net/quic/QUICTransportParameters.cc
@@ -35,35 +35,59 @@ QUICTransportParameters::QUICTransportParameters(const uint8_t *buf, size_t
len)
   memcpy(this->_buf.get(), buf, len);
 }
 
-QUICTransportParameterValue
-QUICTransportParameters::get(QUICTransportParameterId tpid) const
+const uint8_t *
+QUICTransportParameters::get(QUICTransportParameterId tpid, uint16_t &len) const
 {
-  QUICTransportParameterValue value;
-  const uint8_t *p = this->_buf.get() + this->_parameters_offset();
+  if (this->_buf) {
+    const uint8_t *p = this->_buf.get() + this->_parameters_offset();
 
-  uint16_t n = (p[0] << 8) + p[1];
-  p += 2;
-  for (; n > 0; --n) {
-    uint16_t _id = (p[0] << 8) + p[1];
-    p += 2;
-    uint16_t _value_len = (p[0] << 8) + p[1];
+    uint16_t n = (p[0] << 8) + p[1];
     p += 2;
-    if (tpid == _id) {
-      value.data = p;
-      value.len  = _value_len;
-      return value;
+    for (; n > 0; --n) {
+      uint16_t _id = (p[0] << 8) + p[1];
+      p += 2;
+      uint16_t _value_len = (p[0] << 8) + p[1];
+      p += 2;
+      if (tpid == _id) {
+        len = _value_len;
+        return p;
+      }
+      p += _value_len;
+    }
+  } else {
+    auto p = this->_parameters.find(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA);
+    if (p != this->_parameters.end()) {
+      len = p->second->len;
+      return p->second->data.get();
     }
-    p += _value_len;
   }
-  value.data = nullptr;
-  value.len  = 0;
-  return value;
+
+  len = 0;
+  return nullptr;
+}
+
+uint32_t
+QUICTransportParameters::initial_max_stream_data() const
+{
+  uint16_t len        = 0;
+  const uint8_t *data = this->get(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA, len);
+
+  return static_cast<uint32_t>(QUICTypeUtil::read_nbytes_as_uint(data, len));
+}
+
+uint32_t
+QUICTransportParameters::initial_max_data() const
+{
+  uint16_t len        = 0;
+  const uint8_t *data = this->get(QUICTransportParameterId::INITIAL_MAX_DATA, len);
+
+  return static_cast<uint32_t>(QUICTypeUtil::read_nbytes_as_uint(data, len));
 }
 
 void
-QUICTransportParameters::add(QUICTransportParameterId id, QUICTransportParameterValue value)
+QUICTransportParameters::add(QUICTransportParameterId id, std::unique_ptr<QUICTransportParameterValue>
value)
 {
-  _parameters.put(id, value);
+  this->_parameters.insert(std::pair<QUICTransportParameterId, std::unique_ptr<QUICTransportParameterValue>>(id,
std::move(value)));
 }
 
 void
@@ -71,32 +95,32 @@ QUICTransportParameters::store(uint8_t *buf, uint16_t *len) const
 {
   uint8_t *p = buf;
 
-  // Why Map::get() doesn't have const??
-  QUICTransportParameters *me = const_cast<QUICTransportParameters *>(this);
-
   // Write QUIC versions
   this->_store(p, len);
   p += *len;
 
   // Write parameters
-  Vec<QUICTransportParameterId> keys;
-  me->_parameters.get_keys(keys);
-  unsigned int n = keys.length();
-  p[0]           = (n & 0xff00) >> 8;
-  p[1]           = n & 0xff;
-  p += 2;
-  for (unsigned int i = 0; i < n; ++i) {
-    QUICTransportParameterValue value;
-    p[0] = (keys[i] & 0xff00) >> 8;
-    p[1] = keys[i] & 0xff;
+  // XXX parameters_size will be written later
+  uint8_t *parameters_size = p;
+  p += sizeof(uint16_t);
+
+  for (auto &it : this->_parameters) {
+    p[0] = (it.first & 0xff00) >> 8;
+    p[1] = it.first & 0xff;
     p += 2;
-    value = me->_parameters.get(keys[i]);
-    p[0]  = (value.len & 0xff00) >> 8;
-    p[1]  = value.len & 0xff;
+    const QUICTransportParameterValue *value = it.second.get();
+    p[0]                                     = (value->len & 0xff00) >> 8;
+    p[1]                                     = value->len & 0xff;
     p += 2;
-    memcpy(p, value.data, value.len);
-    p += value.len;
+    memcpy(p, value->data.get(), value->len);
+    p += value->len;
   }
+
+  ptrdiff_t n = p - parameters_size - sizeof(uint16_t);
+
+  parameters_size[0] = (n & 0xff00) >> 8;
+  parameters_size[1] = n & 0xff;
+
   *len = (p - buf);
 }
 
@@ -136,9 +160,8 @@ QUICTransportParametersInEncryptedExtensions::_store(uint8_t *buf, uint16_t
*len
   uint8_t *p = buf;
   size_t l;
 
-  p[0] = (this->_n_versions & 0xff00) >> 8;
-  p[1] = this->_n_versions & 0xff;
-  p += 2;
+  p[0] = this->_n_versions * sizeof(uint32_t);
+  ++p;
   for (int i = 0; i < this->_n_versions; ++i) {
     QUICTypeUtil::write_QUICVersion(this->_versions[i], p, &l);
     p += l;
@@ -147,11 +170,11 @@ QUICTransportParametersInEncryptedExtensions::_store(uint8_t *buf, uint16_t
*len
 }
 
 const uint8_t *
-QUICTransportParametersInEncryptedExtensions::supported_versions(uint16_t *n) const
+QUICTransportParametersInEncryptedExtensions::supported_versions_len(uint16_t *n) const
 {
   uint8_t *b = this->_buf.get();
-  *n         = (b[0] << 8) + b[1];
-  return b + 2;
+  *n         = b[0];
+  return b + 1;
 }
 
 void
@@ -164,7 +187,7 @@ std::ptrdiff_t
 QUICTransportParametersInEncryptedExtensions::_parameters_offset() const
 {
   const uint8_t *b = this->_buf.get();
-  return 2 + 4 * ((b[0] << 8) + b[1]);
+  return sizeof(uint8_t) + b[0];
 }
 
 //
diff --git a/iocore/net/quic/QUICTransportParameters.h b/iocore/net/quic/QUICTransportParameters.h
index 40373b4..57814de 100644
--- a/iocore/net/quic/QUICTransportParameters.h
+++ b/iocore/net/quic/QUICTransportParameters.h
@@ -23,9 +23,11 @@
 
 #pragma once
 
+#include <map>
+// #include "ts/Map.h"
+
 #include <openssl/ssl.h>
 #include "QUICTypes.h"
-#include "ts/Map.h"
 #include <cstddef>
 
 class QUICTransportParameterId
@@ -65,9 +67,10 @@ private:
 
 typedef struct _QUICTransportParameterValue {
   _QUICTransportParameterValue(){};
-  _QUICTransportParameterValue(const uint8_t *str) : data(str), len(str ? strlen(reinterpret_cast<const
char *>(str)) : 0){};
-  _QUICTransportParameterValue(const uint8_t *_data, uint16_t _len) : data(_data), len(_len){};
-  const uint8_t *data = nullptr;
+  _QUICTransportParameterValue(ats_unique_buf str)
+    : data(std::move(str)), len(str ? strlen(reinterpret_cast<const char *>(str.get()))
: 0){};
+  _QUICTransportParameterValue(ats_unique_buf _data, uint16_t _len) : data(std::move(_data)),
len(_len){};
+  ats_unique_buf data = {nullptr, [](void *p) { ats_free(p); }};
   uint16_t len        = 0;
 } QUICTransportParameterValue;
 
@@ -75,8 +78,10 @@ class QUICTransportParameters
 {
 public:
   QUICTransportParameters(const uint8_t *buf, size_t len);
-  QUICTransportParameterValue get(QUICTransportParameterId id) const;
-  void add(QUICTransportParameterId id, QUICTransportParameterValue value);
+  const uint8_t *get(QUICTransportParameterId id, uint16_t &len) const;
+  uint32_t initial_max_stream_data() const;
+  uint32_t initial_max_data() const;
+  void add(QUICTransportParameterId id, std::unique_ptr<QUICTransportParameterValue>
value);
   void store(uint8_t *buf, uint16_t *len) const;
 
 protected:
@@ -84,7 +89,8 @@ protected:
   virtual std::ptrdiff_t _parameters_offset() const = 0;
   virtual void _store(uint8_t *buf, uint16_t *len) const = 0;
   ats_unique_buf _buf = {nullptr, [](void *p) { ats_free(p); }};
-  Map<QUICTransportParameterId, QUICTransportParameterValue> _parameters;
+
+  std::map<QUICTransportParameterId, std::unique_ptr<QUICTransportParameterValue>>
_parameters;
 };
 
 class QUICTransportParametersInClientHello : public QUICTransportParameters
@@ -110,7 +116,7 @@ class QUICTransportParametersInEncryptedExtensions : public QUICTransportParamet
 public:
   QUICTransportParametersInEncryptedExtensions() : QUICTransportParameters(){};
   QUICTransportParametersInEncryptedExtensions(const uint8_t *buf, size_t len) : QUICTransportParameters(buf,
len){};
-  const uint8_t *supported_versions(uint16_t *n) const;
+  const uint8_t *supported_versions_len(uint16_t *n) const;
   void add_version(QUICVersion version);
 
 protected:
diff --git a/iocore/net/quic/test/test_QUICTransportParameters.cc b/iocore/net/quic/test/test_QUICTransportParameters.cc
index 864eee6..4977db2 100644
--- a/iocore/net/quic/test/test_QUICTransportParameters.cc
+++ b/iocore/net/quic/test/test_QUICTransportParameters.cc
@@ -30,7 +30,7 @@ TEST_CASE("QUICTransportParametersInClientHello_read", "[quic]")
   uint8_t buf[] = {
     0x01, 0x02, 0x03, 0x04, // negotiated version
     0x05, 0x06, 0x07, 0x08, // iinitial version
-    0x00, 0x04,             // number of parameters
+    0x00, 0x1e,             // size of parameters
     0x00, 0x00,             // parameter id
     0x00, 0x04,             // length of value
     0x11, 0x22, 0x33, 0x44, // value
@@ -48,22 +48,29 @@ TEST_CASE("QUICTransportParametersInClientHello_read", "[quic]")
   QUICTransportParametersInClientHello params_in_ch(buf, sizeof(buf));
   CHECK(params_in_ch.negotiated_version() == 0x01020304);
   CHECK(params_in_ch.initial_version() == 0x05060708);
-  QUICTransportParameterValue value;
-  value = params_in_ch.get(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA);
-  CHECK(value.len == 4);
-  CHECK(memcmp(value.data, "\x11\x22\x33\x44", 4) == 0);
-  value = params_in_ch.get(QUICTransportParameterId::INITIAL_MAX_DATA);
-  CHECK(value.len == 4);
-  CHECK(memcmp(value.data, "\x12\x34\x56\x78", 4) == 0);
-  value = params_in_ch.get(QUICTransportParameterId::INITIAL_MAX_STREAM_ID);
-  CHECK(value.len == 4);
-  CHECK(memcmp(value.data, "\x0a\x0b\x0c\x0d", 4) == 0);
-  value = params_in_ch.get(QUICTransportParameterId::IDLE_TIMEOUT);
-  CHECK(value.len == 2);
-  CHECK(memcmp(value.data, "\xab\xcd", 2) == 0);
-  value = params_in_ch.get(QUICTransportParameterId::MAX_PACKET_SIZE);
-  CHECK(value.len == 0);
-  CHECK(value.data == nullptr);
+
+  uint16_t len        = 0;
+  const uint8_t *data = nullptr;
+
+  data = params_in_ch.get(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA, len);
+  CHECK(len == 4);
+  CHECK(memcmp(data, "\x11\x22\x33\x44", 4) == 0);
+
+  data = params_in_ch.get(QUICTransportParameterId::INITIAL_MAX_DATA, len);
+  CHECK(len == 4);
+  CHECK(memcmp(data, "\x12\x34\x56\x78", 4) == 0);
+
+  data = params_in_ch.get(QUICTransportParameterId::INITIAL_MAX_STREAM_ID, len);
+  CHECK(len == 4);
+  CHECK(memcmp(data, "\x0a\x0b\x0c\x0d", 4) == 0);
+
+  data = params_in_ch.get(QUICTransportParameterId::IDLE_TIMEOUT, len);
+  CHECK(len == 2);
+  CHECK(memcmp(data, "\xab\xcd", 2) == 0);
+
+  data = params_in_ch.get(QUICTransportParameterId::MAX_PACKET_SIZE, len);
+  CHECK(len == 0);
+  CHECK(data == nullptr);
 }
 
 TEST_CASE("QUICTransportParametersInClientHello_write", "[quic]")
@@ -74,7 +81,7 @@ TEST_CASE("QUICTransportParametersInClientHello_write", "[quic]")
   uint8_t expected[] = {
     0x01, 0x02, 0x03, 0x04, // negotiated version
     0x05, 0x06, 0x07, 0x08, // iinitial version
-    0x00, 0x02,             // number of parameters
+    0x00, 0x0e,             // size of parameters
     0x00, 0x00,             // parameter id
     0x00, 0x04,             // length of value
     0x11, 0x22, 0x33, 0x44, // value
@@ -84,8 +91,21 @@ TEST_CASE("QUICTransportParametersInClientHello_write", "[quic]")
   };
 
   QUICTransportParametersInClientHello params_in_ch(0x01020304, 0x05060708);
-  params_in_ch.add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA, {reinterpret_cast<const
uint8_t *>("\x11\x22\x33\x44"), 4});
-  params_in_ch.add(QUICTransportParameterId::MAX_PACKET_SIZE, {reinterpret_cast<const
uint8_t *>("\xab\xcd"), 2});
+
+  size_t max_stream_data_buf_len     = 4;
+  ats_unique_buf max_stream_data_buf = ats_unique_malloc(max_stream_data_buf_len);
+  memcpy(max_stream_data_buf.get(), "\x11\x22\x33\x44", max_stream_data_buf_len);
+  params_in_ch.add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA,
+                   std::unique_ptr<QUICTransportParameterValue>(
+                     new QUICTransportParameterValue(std::move(max_stream_data_buf), max_stream_data_buf_len)));
+
+  uint16_t max_packet_size_buf_len   = 2;
+  ats_unique_buf max_packet_size_buf = ats_unique_malloc(max_packet_size_buf_len);
+  memcpy(max_packet_size_buf.get(), "\xab\xcd", max_packet_size_buf_len);
+  params_in_ch.add(QUICTransportParameterId::MAX_PACKET_SIZE,
+                   std::unique_ptr<QUICTransportParameterValue>(
+                     new QUICTransportParameterValue(std::move(max_packet_size_buf), max_packet_size_buf_len)));
+
   params_in_ch.store(buf, &len);
   CHECK(len == 24);
   CHECK(memcmp(buf, expected, len) == 0);
@@ -94,9 +114,9 @@ TEST_CASE("QUICTransportParametersInClientHello_write", "[quic]")
 TEST_CASE("QUICTransportParametersInEncryptedExtensions_read", "[quic]")
 {
   uint8_t buf[] = {
-    0x00, 0x01,             // number of supported versions
+    0x04,                   // size of supported versions
     0x01, 0x02, 0x03, 0x04, //
-    0x00, 0x04,             // number of parameters
+    0x00, 0x1e,             // size of parameters
     0x00, 0x00,             // parameter id
     0x00, 0x04,             // length of value
     0x11, 0x22, 0x33, 0x44, // value
@@ -113,26 +133,33 @@ TEST_CASE("QUICTransportParametersInEncryptedExtensions_read", "[quic]")
 
   QUICTransportParametersInEncryptedExtensions params_in_ee(buf, sizeof(buf));
   const uint8_t *versions;
-  uint16_t nversion;
-  versions = params_in_ee.supported_versions(&nversion);
-  CHECK(nversion == 1);
+  uint16_t vlen;
+  versions = params_in_ee.supported_versions_len(&vlen);
+  CHECK(vlen == 4);
   CHECK(memcmp(versions, "\x01\x02\x03\x04", 4) == 0);
-  QUICTransportParameterValue value;
-  value = params_in_ee.get(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA);
-  CHECK(value.len == 4);
-  CHECK(memcmp(value.data, "\x11\x22\x33\x44", 4) == 0);
-  value = params_in_ee.get(QUICTransportParameterId::INITIAL_MAX_DATA);
-  CHECK(value.len == 4);
-  CHECK(memcmp(value.data, "\x12\x34\x56\x78", 4) == 0);
-  value = params_in_ee.get(QUICTransportParameterId::INITIAL_MAX_STREAM_ID);
-  CHECK(value.len == 4);
-  CHECK(memcmp(value.data, "\x0a\x0b\x0c\x0d", 4) == 0);
-  value = params_in_ee.get(QUICTransportParameterId::IDLE_TIMEOUT);
-  CHECK(value.len == 2);
-  CHECK(memcmp(value.data, "\xab\xcd", 2) == 0);
-  value = params_in_ee.get(QUICTransportParameterId::MAX_PACKET_SIZE);
-  CHECK(value.len == 0);
-  CHECK(value.data == nullptr);
+
+  uint16_t len        = 0;
+  const uint8_t *data = nullptr;
+
+  data = params_in_ee.get(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA, len);
+  CHECK(len == 4);
+  CHECK(memcmp(data, "\x11\x22\x33\x44", 4) == 0);
+
+  data = params_in_ee.get(QUICTransportParameterId::INITIAL_MAX_DATA, len);
+  CHECK(len == 4);
+  CHECK(memcmp(data, "\x12\x34\x56\x78", 4) == 0);
+
+  data = params_in_ee.get(QUICTransportParameterId::INITIAL_MAX_STREAM_ID, len);
+  CHECK(len == 4);
+  CHECK(memcmp(data, "\x0a\x0b\x0c\x0d", 4) == 0);
+
+  data = params_in_ee.get(QUICTransportParameterId::IDLE_TIMEOUT, len);
+  CHECK(len == 2);
+  CHECK(memcmp(data, "\xab\xcd", 2) == 0);
+
+  data = params_in_ee.get(QUICTransportParameterId::MAX_PACKET_SIZE, len);
+  CHECK(len == 0);
+  CHECK(data == nullptr);
 }
 
 TEST_CASE("QUICTransportParametersEncryptedExtensions_write", "[quic]")
@@ -141,10 +168,10 @@ TEST_CASE("QUICTransportParametersEncryptedExtensions_write", "[quic]")
   uint16_t len;
 
   uint8_t expected[] = {
-    0x00, 0x02,             // number of supported versions
+    0x08,                   // size of supported versions
     0x01, 0x02, 0x03, 0x04, // version 1
     0x05, 0x06, 0x07, 0x08, // version 2
-    0x00, 0x02,             // number of parameters
+    0x00, 0x0e,             // size of parameters
     0x00, 0x00,             // parameter id
     0x00, 0x04,             // length of value
     0x11, 0x22, 0x33, 0x44, // value
@@ -154,11 +181,24 @@ TEST_CASE("QUICTransportParametersEncryptedExtensions_write", "[quic]")
   };
 
   QUICTransportParametersInEncryptedExtensions params_in_ee;
-  params_in_ee.add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA, {reinterpret_cast<const
uint8_t *>("\x11\x22\x33\x44"), 4});
-  params_in_ee.add(QUICTransportParameterId::MAX_PACKET_SIZE, {reinterpret_cast<const
uint8_t *>("\xab\xcd"), 2});
+
+  size_t max_stream_data_buf_len     = 4;
+  ats_unique_buf max_stream_data_buf = ats_unique_malloc(max_stream_data_buf_len);
+  memcpy(max_stream_data_buf.get(), "\x11\x22\x33\x44", max_stream_data_buf_len);
+  params_in_ee.add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA,
+                   std::unique_ptr<QUICTransportParameterValue>(
+                     new QUICTransportParameterValue(std::move(max_stream_data_buf), max_stream_data_buf_len)));
+
+  uint16_t max_packet_size_buf_len   = 2;
+  ats_unique_buf max_packet_size_buf = ats_unique_malloc(max_packet_size_buf_len);
+  memcpy(max_packet_size_buf.get(), "\xab\xcd", max_packet_size_buf_len);
+  params_in_ee.add(QUICTransportParameterId::MAX_PACKET_SIZE,
+                   std::unique_ptr<QUICTransportParameterValue>(
+                     new QUICTransportParameterValue(std::move(max_packet_size_buf), max_packet_size_buf_len)));
+
   params_in_ee.add_version(0x01020304);
   params_in_ee.add_version(0x05060708);
   params_in_ee.store(buf, &len);
-  CHECK(len == 26);
+  CHECK(len == 25);
   CHECK(memcmp(buf, expected, len) == 0);
 }

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

Mime
View raw message