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/12/13 23:44:39 UTC

[trafficserver] 07/08: draft-08: Adjust frame types

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 3d3b174fd8579feb7d5eaa12d927d16861458b85
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Dec 13 10:56:10 2017 +0900

    draft-08: Adjust frame types
---
 iocore/net/quic/QUICFrame.cc           | 12 ++++++------
 iocore/net/quic/QUICTypes.h            |  7 ++++---
 iocore/net/quic/test/test_QUICFrame.cc | 15 ++++++++-------
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc
index 12b09f7..8b2f8ca 100644
--- a/iocore/net/quic/QUICFrame.cc
+++ b/iocore/net/quic/QUICFrame.cc
@@ -50,11 +50,11 @@ QUICFrame::type() const
 QUICFrameType
 QUICFrame::type(const uint8_t *buf)
 {
-  if (buf[0] >= static_cast<uint8_t>(QUICFrameType::STREAM)) {
+  if (buf[0] >= static_cast<uint8_t>(QUICFrameType::UNKNOWN)) {
+    return QUICFrameType::UNKNOWN;
+  } else if (buf[0] >= static_cast<uint8_t>(QUICFrameType::STREAM)) {
     return QUICFrameType::STREAM;
-  } else if (buf[0] >= static_cast<uint8_t>(QUICFrameType::ACK)) {
-    return QUICFrameType::ACK;
-  } else if (buf[0] > static_cast<uint8_t>(QUICFrameType::STOP_SENDING)) {
+  } else if (buf[0] > static_cast<uint8_t>(QUICFrameType::ACK)) {
     return QUICFrameType::UNKNOWN;
   } else {
     return static_cast<QUICFrameType>(buf[0]);
@@ -439,7 +439,7 @@ QUICAckFrame::_get_largest_acknowledged_length() const
    * 1 -> 2 byte
    * 2 -> 4 byte
    * 3 -> 8 byte
-  */
+   */
   int n = (this->_buf[0] & 0x0c) >> 2;
   return 0x01 << n;
 }
@@ -465,7 +465,7 @@ QUICAckFrame::_get_ack_block_length() const
    * 1 -> 2 byte
    * 2 -> 4 byte
    * 3 -> 8 byte
-  */
+   */
   int n = this->_buf[0] & 0x03;
   return 0x01 << n;
 }
diff --git a/iocore/net/quic/QUICTypes.h b/iocore/net/quic/QUICTypes.h
index 7d60131..9a6121a 100644
--- a/iocore/net/quic/QUICTypes.h
+++ b/iocore/net/quic/QUICTypes.h
@@ -97,9 +97,10 @@ enum class QUICFrameType : int {
   STREAM_ID_NEEDED,
   NEW_CONNECTION_ID,
   STOP_SENDING,
-  ACK     = 0xA0,
-  STREAM  = 0xC0,
-  UNKNOWN = 0x100,
+  PONG,
+  ACK,
+  STREAM  = 0x10, // 0x10 - 0x17
+  UNKNOWN = 0x18,
 };
 
 enum class QUICVersionNegotiationStatus {
diff --git a/iocore/net/quic/test/test_QUICFrame.cc b/iocore/net/quic/test/test_QUICFrame.cc
index 3489746..fc09cd4 100644
--- a/iocore/net/quic/test/test_QUICFrame.cc
+++ b/iocore/net/quic/test/test_QUICFrame.cc
@@ -42,15 +42,16 @@ TEST_CASE("QUICFrame Type", "[quic]")
   CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x0a")) == QUICFrameType::STREAM_ID_NEEDED);
   CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x0b")) == QUICFrameType::NEW_CONNECTION_ID);
   CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x0c")) == QUICFrameType::STOP_SENDING);
+  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x0d")) == QUICFrameType::PONG);
+  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x0e")) == QUICFrameType::ACK);
   // Undefined ragne
-  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x0d")) == QUICFrameType::UNKNOWN);
-  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x9f")) == QUICFrameType::UNKNOWN);
-  // Range of ACK
-  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\xa0")) == QUICFrameType::ACK);
-  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\xbf")) == QUICFrameType::ACK);
+  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x0f")) == QUICFrameType::UNKNOWN);
   // Range of STREAM
-  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\xc0")) == QUICFrameType::STREAM);
-  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\xff")) == QUICFrameType::STREAM);
+  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x10")) == QUICFrameType::STREAM);
+  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x17")) == QUICFrameType::STREAM);
+  // Undefined ragne
+  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\x18")) == QUICFrameType::UNKNOWN);
+  CHECK(QUICFrame::type(reinterpret_cast<const uint8_t *>("\xff")) == QUICFrameType::UNKNOWN);
 }
 
 TEST_CASE("Construct QUICFrame", "[quic]")

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