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
The following commit(s) were added to refs/heads/quic-latest by this push: new abab452 Implement PONG abab452 is described below commit abab45200c76b5afb7b4d01e811c95011a5284ef Author: Masakazu Kitajo <mas...@apache.org> AuthorDate: Tue Jan 16 15:20:03 2018 +0900 Implement PONG --- iocore/net/QUICNetVConnection.cc | 5 +++++ iocore/net/quic/QUICFrame.cc | 22 ++++++++++++++++++++++ iocore/net/quic/QUICFrame.h | 10 ++++++++++ 3 files changed, 37 insertions(+) diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc index 87e9c0e..21ccc29 100644 --- a/iocore/net/QUICNetVConnection.cc +++ b/iocore/net/QUICNetVConnection.cc @@ -355,6 +355,11 @@ QUICNetVConnection::handle_frame(std::shared_ptr<const QUICFrame> frame) this->_schedule_packet_write_ready(); break; + case QUICFrameType::PING: + if (std::static_pointer_cast<const QUICPingFrame>(frame)->data_length() > 0) { + this->transmit_frame(QUICFrameFactory::create_pong_frame(*std::static_pointer_cast<const QUICPingFrame>(frame))); + } + break; case QUICFrameType::BLOCKED: // BLOCKED frame is for debugging. Nothing to do here. break; diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc index 252d57c..f7445ee 100644 --- a/iocore/net/quic/QUICFrame.cc +++ b/iocore/net/quic/QUICFrame.cc @@ -1898,6 +1898,28 @@ QUICFrameFactory::create_max_stream_data_frame(QUICStreamId stream_id, uint64_t return std::unique_ptr<QUICMaxStreamDataFrame, QUICFrameDeleterFunc>(frame, &QUICFrameDeleter::delete_max_stream_data_frame); } +std::unique_ptr<QUICPingFrame, QUICFrameDeleterFunc> +QUICFrameFactory::create_ping_frame(const uint8_t *data, size_t data_len) +{ + ats_unique_buf buf = ats_unique_malloc(data_len); + memcpy(buf.get(), data, data_len); + + QUICPingFrame *frame = quicPingFrameAllocator.alloc(); + new (frame) QUICPingFrame(std::move(buf), data_len); + return std::unique_ptr<QUICPingFrame, QUICFrameDeleterFunc>(frame, &QUICFrameDeleter::delete_ping_frame); +} + +std::unique_ptr<QUICPongFrame, QUICFrameDeleterFunc> +QUICFrameFactory::create_pong_frame(const QUICPingFrame &ping_frame) +{ + ats_unique_buf buf = ats_unique_malloc(ping_frame.data_length()); + memcpy(buf.get(), ping_frame.data(), ping_frame.data_length()); + + QUICPongFrame *frame = quicPongFrameAllocator.alloc(); + new (frame) QUICPongFrame(std::move(buf), ping_frame.data_length()); + return std::unique_ptr<QUICPongFrame, QUICFrameDeleterFunc>(frame, &QUICFrameDeleter::delete_pong_frame); +} + std::unique_ptr<QUICBlockedFrame, QUICFrameDeleterFunc> QUICFrameFactory::create_blocked_frame(QUICOffset offset) { diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h index 342defa..0cc90d5 100644 --- a/iocore/net/quic/QUICFrame.h +++ b/iocore/net/quic/QUICFrame.h @@ -753,6 +753,16 @@ public: uint64_t maximum_stream_data); /* + * Creates a PING frame + */ + static std::unique_ptr<QUICPingFrame, QUICFrameDeleterFunc> create_ping_frame(const uint8_t *data, size_t data_len); + + /* + * Creates a PONG frame + */ + static std::unique_ptr<QUICPongFrame, QUICFrameDeleterFunc> create_pong_frame(const QUICPingFrame &ping_frame); + + /* * Creates a BLOCKED frame. */ static std::unique_ptr<QUICBlockedFrame, QUICFrameDeleterFunc> create_blocked_frame(QUICOffset offset); -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].