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:47 UTC

[trafficserver] 01/02: Fix packet size calculation

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>.