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


The following commit(s) were added to refs/heads/quic-latest by this push:
     new 5241e33  [draft-05] Fix error codes
5241e33 is described below

commit 5241e33e39f690f0a7e42acdaf55f2372ae7337b
Author: Masaori Koshiba <masa...@apache.org>
AuthorDate: Mon Sep 11 16:55:46 2017 +0900

    [draft-05] Fix error codes
---
 iocore/net/QUICNetVConnection.cc                |  6 ++---
 iocore/net/quic/QUICDebugNames.cc               | 32 +++++++++++++++++++++----
 iocore/net/quic/QUICFlowController.cc           |  2 +-
 iocore/net/quic/QUICHandshake.cc                |  6 ++---
 iocore/net/quic/QUICStream.cc                   |  2 +-
 iocore/net/quic/QUICTypes.h                     | 28 +++++++++++++++-------
 iocore/net/quic/test/test_QUICFlowController.cc |  4 ++--
 iocore/net/quic/test/test_QUICFrame.cc          | 12 +++++-----
 iocore/net/quic/test/test_QUICStreamManager.cc  |  2 +-
 iocore/net/quic/test/test_QUICStreamState.cc    |  8 +++----
 10 files changed, 68 insertions(+), 34 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index c9654a3..3babca6 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -352,7 +352,7 @@ QUICNetVConnection::state_handshake(int event, Event *data)
       break;
     }
     default:
-      error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+      error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
       break;
     }
 
@@ -538,7 +538,7 @@ 
QUICNetVConnection::_state_handshake_process_initial_client_packet(std::unique_p
 {
   if (packet->size() < MINIMUM_INITIAL_CLIENT_PACKET_SIZE) {
     DebugQUICCon("Packet size is smaller than the minimum initial client 
packet size");
-    return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+    return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
   }
 
   // Start handshake
@@ -625,7 +625,7 @@ QUICNetVConnection::_state_common_receive_packet()
     error = this->_state_connection_established_process_packet(std::move(p));
     break;
   default:
-    error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+    error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
     break;
   }
   return error;
diff --git a/iocore/net/quic/QUICDebugNames.cc 
b/iocore/net/quic/QUICDebugNames.cc
index d580be7..2f79b92 100644
--- a/iocore/net/quic/QUICDebugNames.cc
+++ b/iocore/net/quic/QUICDebugNames.cc
@@ -115,15 +115,39 @@ QUICDebugNames::error_code(QUICErrorCode code)
     return "APPLICATION_SPECIFIC_ERROR";
   case QUICErrorCode::HOST_LOCAL_ERROR:
     return "HOST_LOCAL_ERROR";
-  case QUICErrorCode::QUIC_TRANSPORT_ERROR:
-    return "QUIC_TRANSPORT_ERROR";
-  case QUICErrorCode::QUIC_INTERNAL_ERROR:
-    return "QUIC_INTERNAL_ERROR";
+  case QUICErrorCode::NO_ERROR:
+    return "NO_ERROR";
+  case QUICErrorCode::INTERNAL_ERROR:
+    return "INTERNAL_ERROR";
+  case QUICErrorCode::CANCELLED:
+    return "CANCELLED";
+  case QUICErrorCode::FLOW_CONTROL_ERROR:
+    return "FLOW_CONTROL_ERROR";
+  case QUICErrorCode::STREAM_ID_ERROR:
+    return "STREAM_ID_ERROR";
+  case QUICErrorCode::STREAM_STATE_ERROR:
+    return "STREAM_STATE_ERROR";
+  case QUICErrorCode::FINAL_OFFSET_ERROR:
+    return "FINAL_OFFSET_ERROR";
+  case QUICErrorCode::FRAME_FORMAT_ERROR:
+    return "FRAME_FORMAT_ERROR";
+  case QUICErrorCode::TRANSPORT_PARAMETER_ERROR:
+    return "TRANSPORT_PARAMETER_ERROR";
+  case QUICErrorCode::VERSION_NEGOTIATION_ERROR:
+    return "VERSION_NEGOTIATION_ERROR";
+  case QUICErrorCode::PROTOCOL_VIOLATION:
+    return "PROTOCOL_VIOLATION";
+  case QUICErrorCode::QUIC_RECEIVED_RST:
+    return "QUIC_RECEIVED_RST";
   case QUICErrorCode::CRYPTOGRAPHIC_ERROR:
     return "CRYPTOGRAPHIC_ERROR";
   case QUICErrorCode::TLS_HANDSHAKE_FAILED:
     return "TLS_HANDSHAKE_FAILED";
   default:
+    if ((static_cast<uint32_t>(code) & 0xFFFFFF00) == 
static_cast<uint32_t>(QUICErrorCode::FRAME_ERROR)) {
+      // TODO: Add frame type
+      return "FRAME_ERROR";
+    }
     return "UNKNOWN";
   }
 }
diff --git a/iocore/net/quic/QUICFlowController.cc 
b/iocore/net/quic/QUICFlowController.cc
index ec277e5..77a615d 100644
--- a/iocore/net/quic/QUICFlowController.cc
+++ b/iocore/net/quic/QUICFlowController.cc
@@ -43,7 +43,7 @@ QUICFlowController::update(QUICOffset offset)
   if (this->_offset <= offset) {
     // Assume flow control is not initialized if the limit was 0
     if (this->_limit != 0 && offset > this->_limit) {
-      return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA);
+      return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::FLOW_CONTROL_ERROR);
     }
     this->_offset = offset;
   }
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index 4c94835..9a2584d 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -78,7 +78,7 @@ QUICHandshake::start(const QUICPacket *initial_packet, 
QUICPacketFactory *packet
   // Negotiate version
   if (this->_version_negotiator->status() == 
QUICVersionNegotiationStatus::NOT_NEGOTIATED) {
     if (initial_packet->type() != QUICPacketType::CLIENT_INITIAL) {
-      return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+      return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
     }
     if (initial_packet->version()) {
       if (this->_version_negotiator->negotiate(initial_packet) == 
QUICVersionNegotiationStatus::NEGOTIATED) {
@@ -90,7 +90,7 @@ QUICHandshake::start(const QUICPacket *initial_packet, 
QUICPacketFactory *packet
         Debug(tag, "Version negotiation failed: %x", 
initial_packet->version());
       }
     } else {
-      return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+      return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
     }
   }
   return QUICError(QUICErrorClass::NONE);
@@ -136,7 +136,7 @@ 
QUICHandshake::set_transport_parameters(std::shared_ptr<QUICTransportParameters>
   if (tp_in_ch) {
     // Version revalidation
     if (this->_version_negotiator->revalidate(tp_in_ch) != 
QUICVersionNegotiationStatus::REVALIDATED) {
-      this->_client_qc->close({QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_VERSION_NEGOTIATION_MISMATCH});
+      this->_client_qc->close({QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::VERSION_NEGOTIATION_ERROR});
       Debug(tag, "Enter state_closed");
       SET_HANDLER(&QUICHandshake::state_closed);
       return;
diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc
index 0ca060d..b986148 100644
--- a/iocore/net/quic/QUICStream.cc
+++ b/iocore/net/quic/QUICStream.cc
@@ -289,7 +289,7 @@ QUICStream::recv(const std::shared_ptr<const 
QUICStreamFrame> frame)
   // Check stream state - Do this first before accept the frame
   if (!this->_state.is_allowed_to_receive(*frame)) {
     this->reset();
-    return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+    return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
   }
   this->_state.update_with_received_frame(*frame);
 
diff --git a/iocore/net/quic/QUICTypes.h b/iocore/net/quic/QUICTypes.h
index 787f74e..2d0a095 100644
--- a/iocore/net/quic/QUICTypes.h
+++ b/iocore/net/quic/QUICTypes.h
@@ -124,16 +124,26 @@ enum class QUICErrorClass {
   CRYPTOGRAPHIC,
 };
 
-// TODO: fix for draft-05
 enum class QUICErrorCode : uint32_t {
-  APPLICATION_SPECIFIC_ERROR               = 0,
-  HOST_LOCAL_ERROR                         = 0x40000000,
-  QUIC_TRANSPORT_ERROR                     = 0x80000000,
-  QUIC_INTERNAL_ERROR                      = 0x80000001,
-  QUIC_VERSION_NEGOTIATION_MISMATCH        = 0x80000037,
-  QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA = 0x8000003b,
-  CRYPTOGRAPHIC_ERROR                      = 0xC0000000,
-  TLS_HANDSHAKE_FAILED                     = 0xC000001C,
+  APPLICATION_SPECIFIC_ERROR = 0,
+  HOST_LOCAL_ERROR           = 0x40000000,
+  NO_ERROR                   = 0x80000000,
+  INTERNAL_ERROR,
+  CANCELLED,
+  FLOW_CONTROL_ERROR,
+  STREAM_ID_ERROR,
+  STREAM_STATE_ERROR,
+  FINAL_OFFSET_ERROR,
+  FRAME_FORMAT_ERROR,
+  TRANSPORT_PARAMETER_ERROR,
+  VERSION_NEGOTIATION_ERROR,
+  PROTOCOL_VIOLATION   = 0x8000000A,
+  QUIC_RECEIVED_RST    = 0x80000035,
+  FRAME_ERROR          = 0x80000100,
+  CRYPTOGRAPHIC_ERROR  = 0xC0000000,
+  TLS_HANDSHAKE_FAILED = 0xC000001C,
+  TLS_FATAL_ALERT_GENERATED,
+  TLS_FATAL_ALERT_RECEIVED,
   // TODO Add error codes
 };
 
diff --git a/iocore/net/quic/test/test_QUICFlowController.cc 
b/iocore/net/quic/test/test_QUICFlowController.cc
index 660cad6..9c7996b 100644
--- a/iocore/net/quic/test/test_QUICFlowController.cc
+++ b/iocore/net/quic/test/test_QUICFlowController.cc
@@ -68,7 +68,7 @@ TEST_CASE("QUICFlowController_Local_Connection", "[quic]")
   error = fc.update(1280);
   CHECK(fc.current_offset() == 1024);
   CHECK(fc.current_limit() == 1024);
-  CHECK(error.code == QUICErrorCode::QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA);
+  CHECK(error.code == QUICErrorCode::FLOW_CONTROL_ERROR);
 
   // MAX_STREAM_DATA
   CHECK(tx.frameCount[static_cast<int>(QUICFrameType::MAX_DATA)] == 0);
@@ -180,7 +180,7 @@ TEST_CASE("QUICFlowController_Local_Stream", "[quic]")
   error = fc.update(1280);
   CHECK(fc.current_offset() == 1024);
   CHECK(fc.current_limit() == 1024);
-  CHECK(error.code == QUICErrorCode::QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA);
+  CHECK(error.code == QUICErrorCode::FLOW_CONTROL_ERROR);
 
   // MAX_STREAM_DATA
   CHECK(tx.frameCount[static_cast<int>(QUICFrameType::MAX_STREAM_DATA)] == 0);
diff --git a/iocore/net/quic/test/test_QUICFrame.cc 
b/iocore/net/quic/test/test_QUICFrame.cc
index aa082d6..207664d 100644
--- a/iocore/net/quic/test/test_QUICFrame.cc
+++ b/iocore/net/quic/test/test_QUICFrame.cc
@@ -206,7 +206,7 @@ TEST_CASE("Load RST_STREAM Frame", "[quic]")
   CHECK(frame1->size() == 17);
   std::shared_ptr<const QUICRstStreamFrame> rst_stream_frame1 = 
std::dynamic_pointer_cast<const QUICRstStreamFrame>(frame1);
   CHECK(rst_stream_frame1 != nullptr);
-  CHECK(rst_stream_frame1->error_code() == 
QUICErrorCode::QUIC_TRANSPORT_ERROR);
+  CHECK(rst_stream_frame1->error_code() == QUICErrorCode::NO_ERROR);
   CHECK(rst_stream_frame1->stream_id() == 0x12345678);
   CHECK(rst_stream_frame1->final_offset() == 0x1122334455667788);
 }
@@ -222,7 +222,7 @@ TEST_CASE("Store RST_STREAM Frame", "[quic]")
     0x80, 0x00, 0x00, 0x00,                        // Error Code
     0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 // Final Offset
   };
-  QUICRstStreamFrame rst_stream_frame(0x12345678, 
QUICErrorCode::QUIC_TRANSPORT_ERROR, 0x1122334455667788);
+  QUICRstStreamFrame rst_stream_frame(0x12345678, QUICErrorCode::NO_ERROR, 
0x1122334455667788);
   rst_stream_frame.store(buf, &len);
   CHECK(len == 17);
   CHECK(memcmp(buf, expected, len) == 0);
@@ -294,7 +294,7 @@ TEST_CASE("Load ConnectionClose Frame", "[quic]")
   std::shared_ptr<const QUICConnectionCloseFrame> connectionCloseFrame1 =
     std::dynamic_pointer_cast<const QUICConnectionCloseFrame>(frame1);
   CHECK(connectionCloseFrame1 != nullptr);
-  CHECK(connectionCloseFrame1->error_code() == 
QUICErrorCode::QUIC_TRANSPORT_ERROR);
+  CHECK(connectionCloseFrame1->error_code() == QUICErrorCode::NO_ERROR);
   CHECK(connectionCloseFrame1->reason_phrase_length() == 5);
   CHECK(memcmp(connectionCloseFrame1->reason_phrase(), buf1 + 7, 5) == 0);
 }
@@ -310,7 +310,7 @@ TEST_CASE("Store ConnectionClose Frame", "[quic]")
     0x00, 0x05,                  // Reason Phrase Length
     0x41, 0x42, 0x43, 0x44, 0x45 // Reason Phrase ("ABCDE");
   };
-  QUICConnectionCloseFrame 
connectionCloseFrame(QUICErrorCode::QUIC_TRANSPORT_ERROR, 5, "ABCDE");
+  QUICConnectionCloseFrame connectionCloseFrame(QUICErrorCode::NO_ERROR, 5, 
"ABCDE");
   connectionCloseFrame.store(buf, &len);
   CHECK(len == 12);
   CHECK(memcmp(buf, expected, len) == 0);
@@ -537,7 +537,7 @@ TEST_CASE("Load STOP_SENDING Frame", "[quic]")
   std::shared_ptr<const QUICStopSendingFrame> stop_sending_frame = 
std::dynamic_pointer_cast<const QUICStopSendingFrame>(frame);
   CHECK(stop_sending_frame != nullptr);
   CHECK(stop_sending_frame->stream_id() == 0x12345678);
-  CHECK(stop_sending_frame->error_code() == 
QUICErrorCode::QUIC_TRANSPORT_ERROR);
+  CHECK(stop_sending_frame->error_code() == QUICErrorCode::NO_ERROR);
 }
 
 TEST_CASE("Store STOP_SENDING Frame", "[quic]")
@@ -550,7 +550,7 @@ TEST_CASE("Store STOP_SENDING Frame", "[quic]")
     0x12, 0x34, 0x56, 0x78, // Stream ID
     0x80, 0x00, 0x00, 0x00, // Error Code
   };
-  QUICStopSendingFrame stop_sending_frame(0x12345678, 
QUICErrorCode::QUIC_TRANSPORT_ERROR);
+  QUICStopSendingFrame stop_sending_frame(0x12345678, QUICErrorCode::NO_ERROR);
   stop_sending_frame.store(buf, &len);
   CHECK(len == 9);
   CHECK(memcmp(buf, expected, len) == 0);
diff --git a/iocore/net/quic/test/test_QUICStreamManager.cc 
b/iocore/net/quic/test/test_QUICStreamManager.cc
index 450fbe4..63ed88c 100644
--- a/iocore/net/quic/test/test_QUICStreamManager.cc
+++ b/iocore/net/quic/test/test_QUICStreamManager.cc
@@ -53,7 +53,7 @@ TEST_CASE("QUICStreamManager_NewStream", "[quic]")
   CHECK(sm.stream_count() == 2);
 
   // RST_STREAM frames create new streams
-  std::shared_ptr<QUICFrame> rst_stream_frame = 
QUICFrameFactory::create_rst_stream_frame(2, 
QUICErrorCode::QUIC_INTERNAL_ERROR, 0);
+  std::shared_ptr<QUICFrame> rst_stream_frame = 
QUICFrameFactory::create_rst_stream_frame(2, QUICErrorCode::INTERNAL_ERROR, 0);
   sm.handle_frame(rst_stream_frame);
   CHECK(sm.stream_count() == 3);
 
diff --git a/iocore/net/quic/test/test_QUICStreamState.cc 
b/iocore/net/quic/test/test_QUICStreamState.cc
index a771f66..ec30434 100644
--- a/iocore/net/quic/test/test_QUICStreamState.cc
+++ b/iocore/net/quic/test/test_QUICStreamState.cc
@@ -31,7 +31,7 @@
 TEST_CASE("QUICStreamState_Idle", "[quic]")
 {
   auto stream_frame          = 
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("foo"), 
4, 1, 0);
-  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::QUIC_TRANSPORT_ERROR, 0);
+  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::NO_ERROR, 0);
   auto max_stream_data_frame = 
QUICFrameFactory::create_max_stream_data_frame(0, 0);
   auto stream_blocked_frame  = 
QUICFrameFactory::create_stream_blocked_frame(0);
 
@@ -70,7 +70,7 @@ TEST_CASE("QUICStreamState_Open", "[quic]")
 {
   auto stream_frame          = 
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("foo"), 
4, 1, 0);
   auto stream_frame_with_fin = 
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("bar"), 
4, 1, 0, true);
-  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::QUIC_TRANSPORT_ERROR, 0);
+  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::NO_ERROR, 0);
 
   // Case1. Send FIN in a STREAM
   QUICStreamState ss1;
@@ -105,7 +105,7 @@ TEST_CASE("QUICStreamState_Half_Closed_Remote", "[quic]")
 {
   auto stream_frame          = 
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("foo"), 
4, 1, 0);
   auto stream_frame_with_fin = 
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("bar"), 
4, 1, 0, true);
-  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::QUIC_TRANSPORT_ERROR, 0);
+  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::NO_ERROR, 0);
 
   // Case1. Send FIN in a STREAM
   QUICStreamState ss1;
@@ -126,7 +126,7 @@ TEST_CASE("QUICStreamState_Half_Closed_Local", "[quic]")
 {
   auto stream_frame          = 
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("foo"), 
4, 1, 0);
   auto stream_frame_with_fin = 
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("bar"), 
4, 1, 0, true);
-  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::QUIC_TRANSPORT_ERROR, 0);
+  auto rst_stream_frame      = QUICFrameFactory::create_rst_stream_frame(0, 
QUICErrorCode::NO_ERROR, 0);
 
   // Case1. Recv FIN in a STREAM
   QUICStreamState ss1;

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

Reply via email to