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 fd62dfc Cleanup QUICFrame fd62dfc is described below commit fd62dfc9f51d708ddb4e901057ee2c0e405ec1b2 Author: Masaori Koshiba <masa...@apache.org> AuthorDate: Mon Sep 11 15:47:21 2017 +0900 Cleanup QUICFrame - Replace hard-coded QUICFrameType - Reorder arguments of QUICRstFrame constructor - Use write_QUICStreamId() --- iocore/net/quic/QUICFrame.cc | 32 ++++++++++++++++---------------- iocore/net/quic/QUICFrame.h | 4 ++-- iocore/net/quic/test/test_QUICFrame.cc | 14 +++++++------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc index c8f2229..6a07641 100644 --- a/iocore/net/quic/QUICFrame.cc +++ b/iocore/net/quic/QUICFrame.cc @@ -645,8 +645,8 @@ QUICAckFrame::TimestampSection::store(uint8_t *buf, size_t *len) const // RST_STREAM frame // -QUICRstStreamFrame::QUICRstStreamFrame(QUICErrorCode error_code, QUICStreamId stream_id, QUICOffset final_offset) - : _error_code(error_code), _stream_id(stream_id), _final_offset(final_offset) +QUICRstStreamFrame::QUICRstStreamFrame(QUICStreamId stream_id, QUICErrorCode error_code, QUICOffset final_offset) + : _stream_id(stream_id), _error_code(error_code), _final_offset(final_offset) { } @@ -667,7 +667,7 @@ QUICRstStreamFrame::store(uint8_t *buf, size_t *len) const { size_t n; uint8_t *p = buf; - *p = 0x01; + *p = static_cast<uint8_t>(QUICFrameType::RST_STREAM); ++p; QUICTypeUtil::write_QUICStreamId(this->_stream_id, 4, p, &n); p += n; @@ -727,7 +727,7 @@ QUICPingFrame::size() const void QUICPingFrame::store(uint8_t *buf, size_t *len) const { - buf[0] = 0x07; + buf[0] = static_cast<uint8_t>(QUICFrameType::PING); *len = 1; } @@ -749,7 +749,7 @@ QUICPaddingFrame::size() const void QUICPaddingFrame::store(uint8_t *buf, size_t *len) const { - buf[0] = 0x00; + buf[0] = static_cast<uint8_t>(QUICFrameType::PADDING); *len = 1; } @@ -782,7 +782,7 @@ QUICConnectionCloseFrame::store(uint8_t *buf, size_t *len) const { size_t n; uint8_t *p = buf; - *p = 0x02; + *p = static_cast<uint8_t>(QUICFrameType::CONNECTION_CLOSE); ++p; QUICTypeUtil::write_QUICErrorCode(this->_error_code, p, &n); p += n; @@ -849,7 +849,7 @@ QUICMaxDataFrame::store(uint8_t *buf, size_t *len) const { size_t n; uint8_t *p = buf; - *p = 0x04; + *p = static_cast<uint8_t>(QUICFrameType::MAX_DATA); ++p; QUICTypeUtil::write_uint_as_nbytes(this->_maximum_data, 8, p, &n); p += n; @@ -893,9 +893,9 @@ QUICMaxStreamDataFrame::store(uint8_t *buf, size_t *len) const { size_t n; uint8_t *p = buf; - *p = 0x05; + *p = static_cast<uint8_t>(QUICFrameType::MAX_STREAM_DATA); ++p; - QUICTypeUtil::write_uint_as_nbytes(this->_stream_id, 4, p, &n); + QUICTypeUtil::write_QUICStreamId(this->_stream_id, 4, p, &n); p += n; QUICTypeUtil::write_uint_as_nbytes(this->_maximum_stream_data, 8, p, &n); p += n; @@ -948,7 +948,7 @@ QUICMaxStreamIdFrame::store(uint8_t *buf, size_t *len) const { size_t n; uint8_t *p = buf; - *p = 0x06; + *p = static_cast<uint8_t>(QUICFrameType::MAX_STREAM_ID); ++p; QUICTypeUtil::write_uint_as_nbytes(this->_maximum_stream_id, 4, p, &n); p += n; @@ -984,7 +984,7 @@ QUICBlockedFrame::size() const void QUICBlockedFrame::store(uint8_t *buf, size_t *len) const { - buf[0] = 0x08; + buf[0] = static_cast<uint8_t>(QUICFrameType::BLOCKED); *len = 1; } @@ -1013,9 +1013,9 @@ QUICStreamBlockedFrame::store(uint8_t *buf, size_t *len) const { size_t n; uint8_t *p = buf; - *p = 0x09; + *p = static_cast<uint8_t>(QUICFrameType::STREAM_BLOCKED); ++p; - QUICTypeUtil::write_uint_as_nbytes(this->_stream_id, 4, p, &n); + QUICTypeUtil::write_QUICStreamId(this->_stream_id, 4, p, &n); p += n; *len = p - buf; @@ -1049,7 +1049,7 @@ QUICStreamIdNeededFrame::size() const void QUICStreamIdNeededFrame::store(uint8_t *buf, size_t *len) const { - buf[0] = 0x0a; + buf[0] = static_cast<uint8_t>(QUICFrameType::STREAM_ID_NEEDED); *len = 1; } @@ -1080,7 +1080,7 @@ QUICNewConnectionIdFrame::store(uint8_t *buf, size_t *len) const { size_t n; uint8_t *p = buf; - *p = 0x0b; + *p = static_cast<uint8_t>(QUICFrameType::NEW_CONNECTION_ID); ++p; QUICTypeUtil::write_uint_as_nbytes(this->_sequence, 2, p, &n); p += n; @@ -1352,7 +1352,7 @@ std::unique_ptr<QUICRstStreamFrame, QUICFrameDeleterFunc> QUICFrameFactory::create_rst_stream_frame(QUICStreamId stream_id, QUICErrorCode error_code, QUICOffset final_offset) { QUICRstStreamFrame *frame = quicRstStreamFrameAllocator.alloc(); - new (frame) QUICRstStreamFrame(error_code, stream_id, final_offset); + new (frame) QUICRstStreamFrame(stream_id, error_code, final_offset); return std::unique_ptr<QUICRstStreamFrame, QUICFrameDeleterFunc>(frame, &QUICFrameDeleter::delete_rst_stream_frame); } diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h index e696961..bf65848 100644 --- a/iocore/net/quic/QUICFrame.h +++ b/iocore/net/quic/QUICFrame.h @@ -219,7 +219,7 @@ class QUICRstStreamFrame : public QUICFrame public: QUICRstStreamFrame() : QUICFrame() {} QUICRstStreamFrame(const uint8_t *buf, size_t len) : QUICFrame(buf, len) {} - QUICRstStreamFrame(QUICErrorCode error_code, QUICStreamId stream_id, QUICOffset final_offset); + QUICRstStreamFrame(QUICStreamId stream_id, QUICErrorCode error_code, QUICOffset final_offset); virtual QUICFrameType type() const override; virtual size_t size() const override; virtual void store(uint8_t *buf, size_t *len) const override; @@ -228,8 +228,8 @@ public: QUICOffset final_offset() const; private: + QUICStreamId _stream_id = 0; QUICErrorCode _error_code; - QUICStreamId _stream_id = 0; QUICOffset _final_offset = 0; }; diff --git a/iocore/net/quic/test/test_QUICFrame.cc b/iocore/net/quic/test/test_QUICFrame.cc index 3ebd29a..aa082d6 100644 --- a/iocore/net/quic/test/test_QUICFrame.cc +++ b/iocore/net/quic/test/test_QUICFrame.cc @@ -204,11 +204,11 @@ TEST_CASE("Load RST_STREAM Frame", "[quic]") std::shared_ptr<const QUICFrame> frame1 = QUICFrameFactory::create(buf1, sizeof(buf1)); CHECK(frame1->type() == QUICFrameType::RST_STREAM); CHECK(frame1->size() == 17); - std::shared_ptr<const QUICRstStreamFrame> rstStreamFrame1 = std::dynamic_pointer_cast<const QUICRstStreamFrame>(frame1); - CHECK(rstStreamFrame1 != nullptr); - CHECK(rstStreamFrame1->error_code() == QUICErrorCode::QUIC_TRANSPORT_ERROR); - CHECK(rstStreamFrame1->stream_id() == 0x12345678); - CHECK(rstStreamFrame1->final_offset() == 0x1122334455667788); + 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->stream_id() == 0x12345678); + CHECK(rst_stream_frame1->final_offset() == 0x1122334455667788); } TEST_CASE("Store RST_STREAM Frame", "[quic]") @@ -222,8 +222,8 @@ TEST_CASE("Store RST_STREAM Frame", "[quic]") 0x80, 0x00, 0x00, 0x00, // Error Code 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 // Final Offset }; - QUICRstStreamFrame rstStreamFrame(QUICErrorCode::QUIC_TRANSPORT_ERROR, 0x12345678, 0x1122334455667788); - rstStreamFrame.store(buf, &len); + QUICRstStreamFrame rst_stream_frame(0x12345678, QUICErrorCode::QUIC_TRANSPORT_ERROR, 0x1122334455667788); + rst_stream_frame.store(buf, &len); CHECK(len == 17); CHECK(memcmp(buf, expected, len) == 0); } -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].