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/28 05:22:46 UTC

[trafficserver] branch quic-latest updated (7acc788 -> 668757f)

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

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


    from 7acc788  Fixed build issue with Fedora 26, may be used uninitialized in this function
     new 9b2da8f  Fix packet size calculation
     new 668757f  Rename QUICPacketHeader::length() to size()

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 iocore/net/quic/QUICPacket.cc           | 37 ++++++++++++++++++++-------------
 iocore/net/quic/QUICPacket.h            | 28 ++++++++++++++++++++-----
 iocore/net/quic/test/test_QUICPacket.cc |  4 ++++
 3 files changed, 49 insertions(+), 20 deletions(-)

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

[trafficserver] 02/02: Rename QUICPacketHeader::length() to size()

Posted by ma...@apache.org.
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

commit 668757f0ac9f291323fd05d086dc9e54abcbe34a
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Nov 28 14:22:14 2017 +0900

    Rename QUICPacketHeader::length() to size()
---
 iocore/net/quic/QUICPacket.cc           | 28 ++++++++++++++--------------
 iocore/net/quic/QUICPacket.h            |  6 +++---
 iocore/net/quic/test/test_QUICPacket.cc |  4 ++--
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index b2a0792..651e563 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -197,7 +197,7 @@ uint16_t
 QUICPacketHeader::payload_size() const
 {
   if (this->_buf) {
-    return this->_buf_len - this->length();
+    return this->_buf_len - this->size();
   } else {
     return this->_payload_len;
   }
@@ -217,7 +217,7 @@ QUICPacketLongHeader::key_phase() const
 }
 
 uint16_t
-QUICPacketLongHeader::length() const
+QUICPacketLongHeader::size() const
 {
   return LONGHEADER_LENGTH;
 }
@@ -399,7 +399,7 @@ const uint8_t *
 QUICPacketShortHeader::payload() const
 {
   if (this->_buf) {
-    return this->_buf + length();
+    return this->_buf + this->size();
   } else {
     return this->_payload.get();
   }
@@ -429,7 +429,7 @@ QUICPacketShortHeader::key_phase() const
  * Header Length (doesn't include payload length)
  */
 uint16_t
-QUICPacketShortHeader::length() const
+QUICPacketShortHeader::size() const
 {
   uint16_t len = 1;
 
@@ -570,7 +570,7 @@ QUICPacket::size() const
 uint16_t
 QUICPacket::header_size() const
 {
-  return this->_header->length();
+  return this->_header->size();
 }
 
 uint16_t
@@ -588,9 +588,9 @@ QUICPacket::key_phase() const
 void
 QUICPacket::store(uint8_t *buf, size_t *len) const
 {
-  memcpy(buf, this->_header->buf(), this->_header->length());
-  memcpy(buf + this->_header->length(), this->payload(), this->payload_size());
-  *len = this->_header->length() + this->payload_size();
+  memcpy(buf, this->_header->buf(), this->_header->size());
+  memcpy(buf + this->_header->size(), this->payload(), this->payload_size());
+  *len = this->_header->size() + this->payload_size();
 }
 
 uint8_t
@@ -666,7 +666,7 @@ QUICPacketFactory::create(ats_unique_buf buf, size_t len, QUICPacketNumber base_
   case QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_1:
     if (this->_crypto->is_handshake_finished()) {
       if (this->_crypto->decrypt(plain_txt.get(), plain_txt_len, max_plain_txt_len, header->payload(), header->payload_size(),
-                                 header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                                 header->packet_number(), header->buf(), header->size(), header->key_phase())) {
         result = QUICPacketCreationResult::SUCCESS;
       } else {
         result = QUICPacketCreationResult::FAILED;
@@ -679,7 +679,7 @@ QUICPacketFactory::create(ats_unique_buf buf, size_t len, QUICPacketNumber base_
   case QUICPacketType::CLIENT_CLEARTEXT:
   case QUICPacketType::SERVER_CLEARTEXT:
     if (this->_crypto->decrypt(plain_txt.get(), plain_txt_len, max_plain_txt_len, header->payload(), header->payload_size(),
-                               header->packet_number(), header->buf(), header->length(), QUICKeyPhase::CLEARTEXT)) {
+                               header->packet_number(), header->buf(), header->size(), QUICKeyPhase::CLEARTEXT)) {
       result = QUICPacketCreationResult::SUCCESS;
     } else {
       result = QUICPacketCreationResult::FAILED;
@@ -721,7 +721,7 @@ QUICPacketFactory::create_version_negotiation_packet(const QUICPacket *packet_se
                                                      packet_sent_by_client->packet_number(), base_packet_number,
                                                      packet_sent_by_client->version(), std::move(versions), len);
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, false);
   }
@@ -743,7 +743,7 @@ QUICPacketFactory::create_server_cleartext_packet(QUICConnectionId connection_id
                             base_packet_number, this->_version, std::move(payload), len);
 
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, retransmittable);
   }
@@ -767,7 +767,7 @@ QUICPacketFactory::create_server_protected_packet(QUICConnectionId connection_id
                             base_packet_number, std::move(payload), len);
 
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, retransmittable);
   }
@@ -788,7 +788,7 @@ QUICPacketFactory::create_client_initial_packet(QUICConnectionId connection_id,
     QUICPacketHeader::build(QUICPacketType::CLIENT_INITIAL, connection_id, this->_packet_number_generator.next(),
                             base_packet_number, version, std::move(payload), len);
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, false);
   }
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 308beb0..3b1f799 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -59,7 +59,7 @@ public:
   /*
    * Returns its header size
    */
-  virtual uint16_t length() const = 0;
+  virtual uint16_t size() const = 0;
 
   /*
    * Returns its packet size
@@ -155,7 +155,7 @@ public:
   bool has_connection_id() const;
   QUICKeyPhase key_phase() const;
   bool has_key_phase() const;
-  uint16_t length() const;
+  uint16_t size() const;
   void store(uint8_t *buf, size_t *len) const;
 };
 
@@ -177,7 +177,7 @@ public:
   bool has_connection_id() const;
   QUICKeyPhase key_phase() const;
   bool has_key_phase() const;
-  uint16_t length() const;
+  uint16_t size() const;
   void store(uint8_t *buf, size_t *len) const;
 
 private:
diff --git a/iocore/net/quic/test/test_QUICPacket.cc b/iocore/net/quic/test/test_QUICPacket.cc
index 1bb582f..e2d7863 100644
--- a/iocore/net/quic/test/test_QUICPacket.cc
+++ b/iocore/net/quic/test/test_QUICPacket.cc
@@ -38,7 +38,7 @@ TEST_CASE("QUICPacketHeader", "[quic]")
     };
 
     QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
-    CHECK(header->length() == 17);
+    CHECK(header->size() == 17);
     CHECK(header->packet_size() == 19);
     CHECK(header->type() == QUICPacketType::VERSION_NEGOTIATION);
     CHECK(header->connection_id() == 0x0102030405060708);
@@ -56,7 +56,7 @@ TEST_CASE("QUICPacketHeader", "[quic]")
     };
 
     QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
-    CHECK(header->length() == 13);
+    CHECK(header->size() == 13);
     CHECK(header->packet_size() == 15);
     CHECK(header->connection_id() == 0x0102030405060708);
     CHECK(header->packet_number() == 0x12345678);

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

[trafficserver] 01/02: Fix packet size calculation

Posted by ma...@apache.org.
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

commit 9b2da8fe85ae9b82ca7d12db7917217426b5a25f
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Nov 28 14:18:45 2017 +0900

    Fix packet size calculation
---
 iocore/net/quic/QUICPacket.cc           |  9 ++++++++-
 iocore/net/quic/QUICPacket.h            | 22 ++++++++++++++++++++--
 iocore/net/quic/test/test_QUICPacket.cc |  4 ++++
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index fb7c348..b2a0792 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -51,6 +51,12 @@ QUICPacketHeader::buf()
   }
 }
 
+uint16_t
+QUICPacketHeader::packet_size() const
+{
+  return this->_buf_len;
+}
+
 QUICPacketHeader *
 QUICPacketHeader::load(const uint8_t *buf, size_t len, QUICPacketNumber base)
 {
@@ -557,7 +563,8 @@ QUICPacket::is_retransmittable() const
 uint16_t
 QUICPacket::size() const
 {
-  return this->header_size() + this->payload_size();
+  // This includes not only header size and payload size but also AEAD tag length
+  return this->_header->packet_size();
 }
 
 uint16_t
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index fd390e3..308beb0 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -52,16 +52,21 @@ public:
   virtual const uint8_t *payload() const = 0;
 
   /*
-   * Returns a payload size based on header length and buffer size that is specified to the constructo.
+   * Returns its payload size based on header length and buffer size that is specified to the constructo.
    */
   uint16_t payload_size() const;
 
   /*
-   * Returns a header size
+   * Returns its header size
    */
   virtual uint16_t length() const = 0;
 
   /*
+   * Returns its packet size
+   */
+  uint16_t packet_size() const;
+
+  /*
    * Returns a key phase
    */
   virtual QUICKeyPhase key_phase() const = 0;
@@ -216,9 +221,22 @@ public:
   const QUICPacketHeader *header() const;
   const uint8_t *payload() const;
   bool is_retransmittable() const;
+
+  /*
+   * Size of whole QUIC packet (header + payload + integrity check)
+   */
   uint16_t size() const;
+
+  /*
+   * Size of header
+   */
   uint16_t header_size() const;
+
+  /*
+   * Size of payload
+   */
   uint16_t payload_size() const;
+
   void store(uint8_t *buf, size_t *len) const;
   QUICKeyPhase key_phase() const;
 
diff --git a/iocore/net/quic/test/test_QUICPacket.cc b/iocore/net/quic/test/test_QUICPacket.cc
index 60b35a2..1bb582f 100644
--- a/iocore/net/quic/test/test_QUICPacket.cc
+++ b/iocore/net/quic/test/test_QUICPacket.cc
@@ -38,6 +38,8 @@ TEST_CASE("QUICPacketHeader", "[quic]")
     };
 
     QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
+    CHECK(header->length() == 17);
+    CHECK(header->packet_size() == 19);
     CHECK(header->type() == QUICPacketType::VERSION_NEGOTIATION);
     CHECK(header->connection_id() == 0x0102030405060708);
     CHECK(header->packet_number() == 0x12345678);
@@ -54,6 +56,8 @@ TEST_CASE("QUICPacketHeader", "[quic]")
     };
 
     QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
+    CHECK(header->length() == 13);
+    CHECK(header->packet_size() == 15);
     CHECK(header->connection_id() == 0x0102030405060708);
     CHECK(header->packet_number() == 0x12345678);
   }

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