diff --git a/iocore/net/quic/QUICAckFrameCreator.cc b/iocore/net/quic/QUICAckFrameCreator.cc index 7459e3dbb27..bee2b76bc9d 100644 --- a/iocore/net/quic/QUICAckFrameCreator.cc +++ b/iocore/net/quic/QUICAckFrameCreator.cc @@ -209,7 +209,7 @@ QUICAckFrameManager::QUICAckFrameCreator::push_back(QUICPacketNumber packet_numb } size_t -QUICAckFrameManager::QUICAckFrameCreator::size() +QUICAckFrameManager::QUICAckFrameCreator::size() const { return this->_packet_numbers.size(); } @@ -227,13 +227,13 @@ QUICAckFrameManager::QUICAckFrameCreator::clear() } QUICPacketNumber -QUICAckFrameManager::QUICAckFrameCreator::largest_ack_number() +QUICAckFrameManager::QUICAckFrameCreator::largest_ack_number() const { return this->_largest_ack_number; } ink_hrtime -QUICAckFrameManager::QUICAckFrameCreator::largest_ack_received_time() +QUICAckFrameManager::QUICAckFrameCreator::largest_ack_received_time() const { return this->_largest_ack_received_time; } diff --git a/iocore/net/quic/QUICAckFrameCreator.h b/iocore/net/quic/QUICAckFrameCreator.h index 64a575fa061..55e20f254a9 100644 --- a/iocore/net/quic/QUICAckFrameCreator.h +++ b/iocore/net/quic/QUICAckFrameCreator.h @@ -44,7 +44,7 @@ class QUICAckFrameManager : public QUICFrameGenerator ~QUICAckFrameCreator(); void push_back(QUICPacketNumber packet_number, size_t size, bool ack_only); - size_t size(); + size_t size() const; void clear(); void sort(); void forget(QUICPacketNumber largest_acknowledged); @@ -58,8 +58,8 @@ class QUICAckFrameManager : public QUICFrameGenerator // refresh state when frame lost void refresh_state(); - QUICPacketNumber largest_ack_number(); - ink_hrtime largest_ack_received_time(); + QUICPacketNumber largest_ack_number() const; + ink_hrtime largest_ack_received_time() const; private: uint64_t _calculate_delay(); diff --git a/iocore/net/quic/QUICApplication.cc b/iocore/net/quic/QUICApplication.cc index 54ad68e1137..a5bfd26541f 100644 --- a/iocore/net/quic/QUICApplication.cc +++ b/iocore/net/quic/QUICApplication.cc @@ -115,7 +115,7 @@ QUICStreamIO::consume(int64_t len) } bool -QUICStreamIO::is_read_done() +QUICStreamIO::is_read_done() const { return this->_read_vio->ntodo() == 0; } diff --git a/iocore/net/quic/QUICApplication.h b/iocore/net/quic/QUICApplication.h index dd6d52489bd..c4fb16fd50d 100644 --- a/iocore/net/quic/QUICApplication.h +++ b/iocore/net/quic/QUICApplication.h @@ -46,7 +46,7 @@ class QUICStreamIO int64_t read(uint8_t *buf, int64_t len); int64_t peek(uint8_t *buf, int64_t len); void consume(int64_t len); - bool is_read_done(); + bool is_read_done() const; virtual void read_reenable(); int64_t write(const uint8_t *buf, int64_t len); diff --git a/iocore/net/quic/QUICFlowController.cc b/iocore/net/quic/QUICFlowController.cc index e5b790502fe..c8183060a11 100644 --- a/iocore/net/quic/QUICFlowController.cc +++ b/iocore/net/quic/QUICFlowController.cc @@ -37,7 +37,7 @@ QUICRateAnalyzer::update(QUICOffset offset) } uint64_t -QUICRateAnalyzer::expect_recv_bytes(ink_hrtime time) +QUICRateAnalyzer::expect_recv_bytes(ink_hrtime time) const { return static_cast(time * this->_rate); } diff --git a/iocore/net/quic/QUICFlowController.h b/iocore/net/quic/QUICFlowController.h index 62adf9f0093..3ff183827e6 100644 --- a/iocore/net/quic/QUICFlowController.h +++ b/iocore/net/quic/QUICFlowController.h @@ -33,7 +33,7 @@ class QUICRateAnalyzer { public: void update(QUICOffset offset); - uint64_t expect_recv_bytes(ink_hrtime time); + uint64_t expect_recv_bytes(ink_hrtime time) const; private: double _rate = 0.0; diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc index 8ae02700668..35c14b68390 100644 --- a/iocore/net/quic/QUICFrame.cc +++ b/iocore/net/quic/QUICFrame.cc @@ -895,7 +895,7 @@ QUICAckFrame::AckBlockSection::first_ack_block() const } void -QUICAckFrame::AckBlockSection::add_ack_block(AckBlock block) +QUICAckFrame::AckBlockSection::add_ack_block(const AckBlock &block) { this->_ack_blocks.push_back(block); } @@ -2960,7 +2960,8 @@ QUICFrameFactory::create_connection_close_frame(uint8_t *buf, uint16_t error_cod } QUICConnectionCloseFrame * -QUICFrameFactory::create_connection_close_frame(uint8_t *buf, QUICConnectionError &error, QUICFrameId id, QUICFrameGenerator *owner) +QUICFrameFactory::create_connection_close_frame(uint8_t *buf, const QUICConnectionError &error, QUICFrameId id, + QUICFrameGenerator *owner) { ink_assert(error.cls == QUICErrorClass::TRANSPORT); if (error.msg) { diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h index 65cfa44b2ab..93cd692fc7c 100644 --- a/iocore/net/quic/QUICFrame.h +++ b/iocore/net/quic/QUICFrame.h @@ -234,7 +234,7 @@ class QUICAckFrame : public QUICFrame size_t size() const; Ptr to_io_buffer_block(size_t limit) const; uint64_t first_ack_block() const; - void add_ack_block(const AckBlock block); + void add_ack_block(const AckBlock &block); const_iterator begin() const; const_iterator end() const; bool has_protected() const; @@ -800,7 +800,7 @@ class QUICFrameFactory const char *reason_phrase = nullptr, QUICFrameId id = 0, QUICFrameGenerator *owner = nullptr); - static QUICConnectionCloseFrame *create_connection_close_frame(uint8_t *buf, QUICConnectionError &error, QUICFrameId id = 0, + static QUICConnectionCloseFrame *create_connection_close_frame(uint8_t *buf, const QUICConnectionError &error, QUICFrameId id = 0, QUICFrameGenerator *owner = nullptr); /* diff --git a/iocore/net/quic/QUICFrameRetransmitter.h b/iocore/net/quic/QUICFrameRetransmitter.h index 9f45dd5b959..64f1f9536af 100644 --- a/iocore/net/quic/QUICFrameRetransmitter.h +++ b/iocore/net/quic/QUICFrameRetransmitter.h @@ -36,7 +36,7 @@ struct QUICFrameInformation { }; struct QUICFrameInformationDeleter { - void operator()(QUICFrameInformation *p); + void operator()(QUICFrameInformation *p) const; }; using QUICFrameInformationUPtr = std::unique_ptr; @@ -90,7 +90,7 @@ class QUICFrameRetransmitter extern ClassAllocator quicFrameInformationAllocator; inline void -QUICFrameInformationDeleter::operator()(QUICFrameInformation *p) +QUICFrameInformationDeleter::operator()(QUICFrameInformation *p) const { quicFrameInformationAllocator.free(p); } diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc index 01baf353833..f64f2221315 100644 --- a/iocore/net/quic/QUICHandshake.cc +++ b/iocore/net/quic/QUICHandshake.cc @@ -212,20 +212,20 @@ QUICHandshake::has_remote_tp() const } QUICVersion -QUICHandshake::negotiated_version() +QUICHandshake::negotiated_version() const { return this->_version_negotiator->negotiated_version(); } // Similar to SSLNetVConnection::getSSLCipherSuite() const char * -QUICHandshake::negotiated_cipher_suite() +QUICHandshake::negotiated_cipher_suite() const { return this->_hs_protocol->negotiated_cipher_suite(); } void -QUICHandshake::negotiated_application_name(const uint8_t **name, unsigned int *len) +QUICHandshake::negotiated_application_name(const uint8_t **name, unsigned int *len) const { this->_hs_protocol->negotiated_application_name(name, len); } diff --git a/iocore/net/quic/QUICHandshake.h b/iocore/net/quic/QUICHandshake.h index e48f87ee43f..4f55985badf 100644 --- a/iocore/net/quic/QUICHandshake.h +++ b/iocore/net/quic/QUICHandshake.h @@ -73,9 +73,9 @@ class QUICHandshake : public QUICFrameHandler, public QUICFrameGenerator bool check_remote_transport_parameters(); // Getters - QUICVersion negotiated_version(); - const char *negotiated_cipher_suite(); - void negotiated_application_name(const uint8_t **name, unsigned int *len); + QUICVersion negotiated_version() const; + const char *negotiated_cipher_suite() const; + void negotiated_application_name(const uint8_t **name, unsigned int *len) const; std::shared_ptr local_transport_parameters(); std::shared_ptr remote_transport_parameters(); diff --git a/iocore/net/quic/QUICLossDetector.cc b/iocore/net/quic/QUICLossDetector.cc index 36b947528ca..a52ec684d42 100644 --- a/iocore/net/quic/QUICLossDetector.cc +++ b/iocore/net/quic/QUICLossDetector.cc @@ -118,7 +118,7 @@ QUICLossDetector::handle_frame(QUICEncryptionLevel level, const QUICFrame &frame } QUICPacketNumber -QUICLossDetector::largest_acked_packet_number(QUICPacketNumberSpace pn_space) +QUICLossDetector::largest_acked_packet_number(QUICPacketNumberSpace pn_space) const { int index = static_cast(pn_space); return this->_largest_acked_packet[index]; @@ -252,7 +252,7 @@ QUICLossDetector::_on_ack_received(const QUICAckFrame &ack_frame, QUICPacketNumb // If the largest acknowledged is newly acked and // ack-eliciting, update the RTT. - auto &largest_acked = newly_acked_packets[0]; + const auto &largest_acked = newly_acked_packets[0]; if (largest_acked->packet_number == ack_frame.largest_acknowledged() && this->_include_ack_eliciting(newly_acked_packets)) { ink_hrtime latest_rtt = Thread::get_hrtime() - largest_acked->time_sent; // _latest_rtt is nanosecond but ack_frame.ack_delay is microsecond and scaled @@ -372,7 +372,7 @@ QUICLossDetector::_get_pto_time_and_space(QUICPacketNumberSpace &space) } bool -QUICLossDetector::_peer_completed_address_validation() +QUICLossDetector::_peer_completed_address_validation() const { return this->_context.connection_info()->is_address_validation_completed(); } @@ -592,12 +592,12 @@ QUICLossDetector::_send_one_ack_eliciting_padded_initial_packet() // ===== Functions below are helper functions ===== void -QUICLossDetector::_retransmit_lost_packet(QUICSentPacketInfo &packet_info) +QUICLossDetector::_retransmit_lost_packet(const QUICSentPacketInfo &packet_info) { SCOPED_MUTEX_LOCK(lock, this->_loss_detection_mutex, this_ethread()); QUICLDDebug("Retransmit %s packet #%" PRIu64, QUICDebugNames::packet_type(packet_info.type), packet_info.packet_number); - for (QUICSentPacketInfo::FrameInfo &frame_info : packet_info.frames) { + for (const QUICSentPacketInfo::FrameInfo &frame_info : packet_info.frames) { auto reactor = frame_info.generated_by(); if (reactor == nullptr) { continue; diff --git a/iocore/net/quic/QUICLossDetector.h b/iocore/net/quic/QUICLossDetector.h index cf10d1286bf..5ed1c228b7a 100644 --- a/iocore/net/quic/QUICLossDetector.h +++ b/iocore/net/quic/QUICLossDetector.h @@ -62,7 +62,7 @@ class QUICLossDetector : public Continuation, public QUICFrameHandler // OnPacketNumberSpaceDiscarded is on Congestion Control section but having it here makes more sense because most processes are // for LD. void on_packet_number_space_discarded(QUICPacketNumberSpace pn_space); - QUICPacketNumber largest_acked_packet_number(QUICPacketNumberSpace pn_space); + QUICPacketNumber largest_acked_packet_number(QUICPacketNumberSpace pn_space) const; void update_ack_delay_exponent(uint8_t ack_delay_exponent); void reset(); @@ -109,11 +109,11 @@ class QUICLossDetector : public Continuation, public QUICFrameHandler std::map _detect_and_remove_lost_packets(QUICPacketNumberSpace pn_space); void _set_loss_detection_timer(); void _on_loss_detection_timeout(); - void _retransmit_lost_packet(QUICSentPacketInfo &packet_info); + void _retransmit_lost_packet(const QUICSentPacketInfo &packet_info); ink_hrtime _get_loss_time_and_space(QUICPacketNumberSpace &space); ink_hrtime _get_pto_time_and_space(QUICPacketNumberSpace &space); - bool _peer_completed_address_validation(); + bool _peer_completed_address_validation() const; std::vector _detect_and_remove_acked_packets(const QUICAckFrame &ack_frame, QUICPacketNumberSpace pn_space); diff --git a/iocore/net/quic/QUICNewRenoCongestionController.cc b/iocore/net/quic/QUICNewRenoCongestionController.cc index 321c1f6a3a4..7745670082d 100644 --- a/iocore/net/quic/QUICNewRenoCongestionController.cc +++ b/iocore/net/quic/QUICNewRenoCongestionController.cc @@ -69,7 +69,7 @@ QUICNewRenoCongestionController::on_packet_sent(size_t bytes_sent) } bool -QUICNewRenoCongestionController::_in_congestion_recovery(ink_hrtime sent_time) +QUICNewRenoCongestionController::_in_congestion_recovery(ink_hrtime sent_time) const { return sent_time <= this->_congestion_recovery_start_time; } diff --git a/iocore/net/quic/QUICNewRenoCongestionController.h b/iocore/net/quic/QUICNewRenoCongestionController.h index ab624fb03d6..43a870ccc53 100644 --- a/iocore/net/quic/QUICNewRenoCongestionController.h +++ b/iocore/net/quic/QUICNewRenoCongestionController.h @@ -55,7 +55,7 @@ class QUICNewRenoCongestionController : public QUICCongestionController bool _check_credit() const; // Appendix B. Congestion Control Pseudocode - bool _in_congestion_recovery(ink_hrtime sent_time); + bool _in_congestion_recovery(ink_hrtime sent_time) const; void _congestion_event(ink_hrtime sent_time); bool _in_persistent_congestion(const std::map &lost_packets, const QUICSentPacketInfoUPtr &largest_lost_packet); diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc index 95dc5770efb..5f5707dceed 100644 --- a/iocore/net/quic/QUICPacket.cc +++ b/iocore/net/quic/QUICPacket.cc @@ -333,8 +333,8 @@ QUICPacketR::read_essential_info(Ptr block, QUICPacketType &type, // // QUICLongHeaderPacket // -QUICLongHeaderPacket::QUICLongHeaderPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, bool ack_eliciting, - bool probing, bool crypto) +QUICLongHeaderPacket::QUICLongHeaderPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, + bool ack_eliciting, bool probing, bool crypto) : QUICPacket(ack_eliciting, probing), _version(version), _dcid(dcid), _scid(scid), _is_crypto_packet(crypto) { } @@ -567,7 +567,7 @@ QUICLongHeaderPacketR::packet_number_offset(size_t &pn_offset, const uint8_t *pa // // QUICShortHeaderPacket // -QUICShortHeaderPacket::QUICShortHeaderPacket(QUICConnectionId dcid, QUICPacketNumber packet_number, +QUICShortHeaderPacket::QUICShortHeaderPacket(const QUICConnectionId &dcid, QUICPacketNumber packet_number, QUICPacketNumber base_packet_number, QUICKeyPhase key_phase, bool ack_eliciting, bool probing) : QUICPacket(ack_eliciting, probing), _dcid(dcid), _packet_number(packet_number), _key_phase(key_phase) @@ -883,7 +883,8 @@ QUICStatelessResetPacketR::destination_cid() const // // QUICVersionNegotiationPacket // -QUICVersionNegotiationPacket::QUICVersionNegotiationPacket(QUICConnectionId dcid, QUICConnectionId scid, + +QUICVersionNegotiationPacket::QUICVersionNegotiationPacket(const QUICConnectionId &dcid, const QUICConnectionId &scid, const QUICVersion versions[], int nversions, QUICVersion version_in_initial) : QUICLongHeaderPacket(0, dcid, scid, false, false, false), @@ -1080,9 +1081,9 @@ QUICVersionNegotiationPacketR::nversions() const // // QUICInitialPacket // -QUICInitialPacket::QUICInitialPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, size_t token_len, - ats_unique_buf token, size_t length, QUICPacketNumber packet_number, bool ack_eliciting, - bool probing, bool crypto) +QUICInitialPacket::QUICInitialPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, + size_t token_len, ats_unique_buf token, size_t length, QUICPacketNumber packet_number, + bool ack_eliciting, bool probing, bool crypto) : QUICLongHeaderPacket(version, dcid, scid, ack_eliciting, probing, crypto), _token_len(token_len), _token(std::move(token)), @@ -1318,7 +1319,7 @@ QUICInitialPacketR::token_length(size_t &token_length, uint8_t &field_len, size_ // // QUICZeroRttPacket // -QUICZeroRttPacket::QUICZeroRttPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, size_t length, +QUICZeroRttPacket::QUICZeroRttPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, size_t length, QUICPacketNumber packet_number, bool ack_eliciting, bool probing) : QUICLongHeaderPacket(version, dcid, scid, ack_eliciting, probing, false), _packet_number(packet_number) { @@ -1497,8 +1498,9 @@ QUICZeroRttPacketR::attach_payload(Ptr payload, bool unprotected) // // QUICHandshakePacket // -QUICHandshakePacket::QUICHandshakePacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, size_t length, - QUICPacketNumber packet_number, bool ack_eliciting, bool probing, bool crypto) +QUICHandshakePacket::QUICHandshakePacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, + size_t length, QUICPacketNumber packet_number, bool ack_eliciting, bool probing, + bool crypto) : QUICLongHeaderPacket(version, dcid, scid, ack_eliciting, probing, crypto), _packet_number(packet_number) { } @@ -1676,7 +1678,8 @@ QUICHandshakePacketR::attach_payload(Ptr payload, bool unprotecte // // QUICRetryPacket // -QUICRetryPacket::QUICRetryPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, QUICRetryToken &token) +QUICRetryPacket::QUICRetryPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, + QUICRetryToken &token) : QUICLongHeaderPacket(version, dcid, scid, false, false, false), _token(token) { } @@ -1841,7 +1844,7 @@ QUICRetryPacketR::token() const } bool -QUICRetryPacketR::has_valid_tag(QUICConnectionId &odcid) const +QUICRetryPacketR::has_valid_tag(const QUICConnectionId &odcid) const { uint8_t tag_computed[QUICRetryIntegrityTag::LEN]; QUICRetryIntegrityTag::compute(tag_computed, this->version(), odcid, this->_header_block, this->_payload_block_without_tag); diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h index 0af44832174..e9d02127328 100644 --- a/iocore/net/quic/QUICPacket.h +++ b/iocore/net/quic/QUICPacket.h @@ -168,8 +168,8 @@ class QUICLongHeaderPacket : public QUICPacket /** * For sending packet */ - QUICLongHeaderPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, bool ack_eliciting, bool probing, - bool crypto); + QUICLongHeaderPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, bool ack_eliciting, + bool probing, bool crypto); QUICConnectionId source_cid() const; @@ -226,7 +226,7 @@ class QUICShortHeaderPacket : public QUICPacket /** * For sending packet */ - QUICShortHeaderPacket(QUICConnectionId dcid, QUICPacketNumber packet_number, QUICPacketNumber base_packet_number, + QUICShortHeaderPacket(const QUICConnectionId &dcid, QUICPacketNumber packet_number, QUICPacketNumber base_packet_number, QUICKeyPhase key_phase, bool ack_eliciting, bool probing); QUICPacketType type() const override; @@ -319,8 +319,8 @@ class QUICVersionNegotiationPacket : public QUICLongHeaderPacket /** * For sending packet */ - QUICVersionNegotiationPacket(QUICConnectionId dcid, QUICConnectionId scid, const QUICVersion versions[], int nversions, - QUICVersion version_in_initial); + QUICVersionNegotiationPacket(const QUICConnectionId &dcid, const QUICConnectionId &scid, const QUICVersion versions[], + int nversions, QUICVersion version_in_initial); QUICPacketType type() const override; QUICVersion version() const override; @@ -369,8 +369,9 @@ class QUICInitialPacket : public QUICLongHeaderPacket /** * For sending packet */ - QUICInitialPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, size_t token_len, ats_unique_buf token, - size_t length, QUICPacketNumber packet_number, bool ack_eliciting, bool probing, bool crypto); + QUICInitialPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, size_t token_len, + ats_unique_buf token, size_t length, QUICPacketNumber packet_number, bool ack_eliciting, bool probing, + bool crypto); QUICPacketType type() const override; QUICPacketNumber packet_number() const override; @@ -425,7 +426,7 @@ class QUICZeroRttPacket : public QUICLongHeaderPacket /** * For sending packet */ - QUICZeroRttPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, size_t length, + QUICZeroRttPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, size_t length, QUICPacketNumber packet_number, bool ack_eliciting, bool probing); QUICPacketType type() const override; @@ -467,7 +468,7 @@ class QUICHandshakePacket : public QUICLongHeaderPacket /** * For sending packet */ - QUICHandshakePacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, size_t length, + QUICHandshakePacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, size_t length, QUICPacketNumber packet_number, bool ack_eliciting, bool probing, bool crypto); QUICPacketType type() const override; @@ -509,7 +510,7 @@ class QUICRetryPacket : public QUICLongHeaderPacket /** * For sending packet */ - QUICRetryPacket(QUICVersion version, QUICConnectionId dcid, QUICConnectionId scid, QUICRetryToken &token); + QUICRetryPacket(QUICVersion version, const QUICConnectionId &dcid, const QUICConnectionId &scid, QUICRetryToken &token); QUICPacketType type() const override; QUICPacketNumber packet_number() const override; @@ -543,7 +544,7 @@ class QUICRetryPacketR : public QUICLongHeaderPacketR QUICPacketNumber packet_number() const override; const QUICAddressValidationToken &token() const; - bool has_valid_tag(QUICConnectionId &odcid) const; + bool has_valid_tag(const QUICConnectionId &odcid) const; private: QUICAddressValidationToken *_token = nullptr; diff --git a/iocore/net/quic/QUICPacketReceiveQueue.cc b/iocore/net/quic/QUICPacketReceiveQueue.cc index f19779099f9..a2aee1bd726 100644 --- a/iocore/net/quic/QUICPacketReceiveQueue.cc +++ b/iocore/net/quic/QUICPacketReceiveQueue.cc @@ -186,7 +186,7 @@ QUICPacketReceiveQueue::dequeue(uint8_t *packet_buf, QUICPacketCreationResult &r } uint32_t -QUICPacketReceiveQueue::size() +QUICPacketReceiveQueue::size() const { return this->_queue.size; } diff --git a/iocore/net/quic/QUICPacketReceiveQueue.h b/iocore/net/quic/QUICPacketReceiveQueue.h index 78e5b00a18a..3ebded31de2 100644 --- a/iocore/net/quic/QUICPacketReceiveQueue.h +++ b/iocore/net/quic/QUICPacketReceiveQueue.h @@ -38,7 +38,7 @@ class QUICPacketReceiveQueue void enqueue(UDPPacket *packet); QUICPacketUPtr dequeue(uint8_t *packet_buf, QUICPacketCreationResult &result); - uint32_t size(); + uint32_t size() const; void reset(); private: diff --git a/iocore/net/quic/QUICPathValidator.cc b/iocore/net/quic/QUICPathValidator.cc index 21a97c91c5f..e12022c75b4 100644 --- a/iocore/net/quic/QUICPathValidator.cc +++ b/iocore/net/quic/QUICPathValidator.cc @@ -50,7 +50,7 @@ QUICPathValidator::ValidationJob::consume_challenge() } bool -QUICPathValidator::is_validating(const QUICPath &path) +QUICPathValidator::is_validating(const QUICPath &path) const { if (auto j = this->_jobs.find(path); j != this->_jobs.end()) { return j->second.is_validating(); @@ -60,7 +60,7 @@ QUICPathValidator::is_validating(const QUICPath &path) } bool -QUICPathValidator::is_validated(const QUICPath &path) +QUICPathValidator::is_validated(const QUICPath &path) const { if (auto j = this->_jobs.find(path); j != this->_jobs.end()) { return j->second.is_validated(); @@ -82,13 +82,13 @@ QUICPathValidator::validate(const QUICPath &path) } bool -QUICPathValidator::ValidationJob::is_validating() +QUICPathValidator::ValidationJob::is_validating() const { return this->_state == ValidationState::VALIDATING; } bool -QUICPathValidator::ValidationJob::is_validated() +QUICPathValidator::ValidationJob::is_validated() const { return this->_state == ValidationState::VALIDATED; } diff --git a/iocore/net/quic/QUICPathValidator.h b/iocore/net/quic/QUICPathValidator.h index e06c64e18ec..96f5f4f64c3 100644 --- a/iocore/net/quic/QUICPathValidator.h +++ b/iocore/net/quic/QUICPathValidator.h @@ -37,8 +37,8 @@ class QUICPathValidator : public QUICFrameHandler, public QUICFrameGenerator : _cinfo(info), _on_validation_callback(callback) { } - bool is_validating(const QUICPath &path); - bool is_validated(const QUICPath &path); + bool is_validating(const QUICPath &path) const; + bool is_validated(const QUICPath &path) const; void validate(const QUICPath &path); // QUICFrameHandler @@ -62,8 +62,8 @@ class QUICPathValidator : public QUICFrameHandler, public QUICFrameGenerator public: ValidationJob(){}; ~ValidationJob(){}; - bool is_validating(); - bool is_validated(); + bool is_validating() const; + bool is_validated() const; void start(); bool validate_response(const uint8_t *data); bool has_more_challenges() const; diff --git a/iocore/net/quic/QUICTransportParameters.h b/iocore/net/quic/QUICTransportParameters.h index 981d6ab611b..72533843105 100644 --- a/iocore/net/quic/QUICTransportParameters.h +++ b/iocore/net/quic/QUICTransportParameters.h @@ -61,7 +61,7 @@ class QUICTransportParameterId } bool - operator==(uint16_t &x) const + operator==(const uint16_t &x) const { return this->_id == x; } diff --git a/iocore/net/quic/QUICVersionNegotiator.cc b/iocore/net/quic/QUICVersionNegotiator.cc index e08504ce52c..43d2fbf5631 100644 --- a/iocore/net/quic/QUICVersionNegotiator.cc +++ b/iocore/net/quic/QUICVersionNegotiator.cc @@ -25,7 +25,7 @@ #include "QUICTransportParameters.h" QUICVersionNegotiationStatus -QUICVersionNegotiator::status() +QUICVersionNegotiator::status() const { return this->_status; } @@ -70,13 +70,13 @@ QUICVersionNegotiator::negotiate(const QUICPacket &packet) } QUICVersionNegotiationStatus -QUICVersionNegotiator::validate() +QUICVersionNegotiator::validate() const { return this->_status; } QUICVersion -QUICVersionNegotiator::negotiated_version() +QUICVersionNegotiator::negotiated_version() const { return this->_negotiated_version; } diff --git a/iocore/net/quic/QUICVersionNegotiator.h b/iocore/net/quic/QUICVersionNegotiator.h index 55068f036ec..392154e614e 100644 --- a/iocore/net/quic/QUICVersionNegotiator.h +++ b/iocore/net/quic/QUICVersionNegotiator.h @@ -34,10 +34,10 @@ class QUICVersionNegotiator { public: - QUICVersionNegotiationStatus status(); + QUICVersionNegotiationStatus status() const; QUICVersionNegotiationStatus negotiate(const QUICPacket &initial_packet); - QUICVersionNegotiationStatus validate(); - QUICVersion negotiated_version(); + QUICVersionNegotiationStatus validate() const; + QUICVersion negotiated_version() const; private: QUICVersion _negotiated_version = 0; diff --git a/iocore/net/quic/qlog/QLog.cc b/iocore/net/quic/qlog/QLog.cc index f94fb398de1..71bb5fcca6e 100644 --- a/iocore/net/quic/qlog/QLog.cc +++ b/iocore/net/quic/qlog/QLog.cc @@ -74,7 +74,7 @@ Trace::encode(YAML::Node &node) } void -QLog::dump(std::string dir) +QLog::dump(const std::string &dir) { YAML::Node root; root["qlog_version"] = this->_ver; diff --git a/iocore/net/quic/qlog/QLog.h b/iocore/net/quic/qlog/QLog.h index 2407d58202d..c40bb472801 100644 --- a/iocore/net/quic/qlog/QLog.h +++ b/iocore/net/quic/qlog/QLog.h @@ -46,9 +46,13 @@ class Trace VantagePointType flow = VantagePointType::unknown; }; - Trace(std::string odcid, std::string title = "", std::string desc = "") : _reference_time(Thread::get_hrtime()), _odcid(odcid) {} + Trace(const std::string &odcid, const std::string &title = "", const std::string &desc = "") + : _reference_time(Thread::get_hrtime()), _odcid(odcid) + { + } - Trace(const VantagePoint &vp, std::string odcid, std::string title = "", std::string desc = "") : Trace(odcid, title, desc) + Trace(const VantagePoint &vp, const std::string &odcid, const std::string &title = "", const std::string &desc = "") + : Trace(odcid, title, desc) { set_vantage_point(vp); } @@ -71,7 +75,7 @@ class Trace } void - set_vantage_point(const VantagePoint vp) + set_vantage_point(const VantagePoint &vp) { this->_vp = vp; } @@ -107,10 +111,13 @@ class QLog public: static constexpr char QLOG_VERSION[] = "draft-01"; - QLog(std::string title = "", std::string desc = "", std::string ver = QLOG_VERSION) : _title(title), _desc(desc), _ver(ver) {} + QLog(const std::string &title = "", const std::string &desc = "", const std::string &ver = QLOG_VERSION) + : _title(title), _desc(desc), _ver(ver) + { + } Trace & - new_trace(Trace::VantagePoint vp, std::string odcid, std::string title = "", std::string desc = "") + new_trace(Trace::VantagePoint vp, const std::string &odcid, const std::string &title = "", const std::string &desc = "") { this->_traces.push_back(std::make_unique(vp, odcid, title, desc)); return *this->_traces.back().get(); @@ -133,7 +140,7 @@ class QLog return *this->_traces.back().get(); } - void dump(std::string dir); + void dump(const std::string &dir); private: std::string _title; diff --git a/iocore/net/quic/qlog/QLogEvent.h b/iocore/net/quic/qlog/QLogEvent.h index a03f7cc4f32..553a34835a4 100644 --- a/iocore/net/quic/qlog/QLogEvent.h +++ b/iocore/net/quic/qlog/QLogEvent.h @@ -75,7 +75,7 @@ struct PacketHeader { // Note: short vs long header is implicit through PacketType void - encode(YAML::Node &node) + encode(YAML::Node &node) const { node["packet_number"] = packet_number; node["packet_size"] = packet_size; @@ -90,7 +90,7 @@ struct PacketHeader { #define SET_FUNC(cla, field, type) \ public: \ - cla &set_##field(type v) \ + cla &set_##field(const type &v) \ { \ this->_##field = v; \ return *this; \ @@ -173,7 +173,8 @@ namespace Connectivity class ConnectionStarted : public ConnectivityEvent { public: - ConnectionStarted(std::string version, std::string sip, std::string dip, int sport, int dport, std::string protocol = "QUIC") + ConnectionStarted(const std::string &version, const std::string &sip, const std::string &dip, int sport, int dport, + const std::string &protocol = "QUIC") { set_ip_version(version); set_protocol(protocol); @@ -211,7 +212,7 @@ namespace Connectivity class ConnectionIdUpdated : public ConnectivityEvent { public: - ConnectionIdUpdated(std::string old, std::string n, bool peer = false) + ConnectionIdUpdated(const std::string &old, const std::string &n, bool peer = false) { if (peer) { set_dst_old(old); @@ -345,7 +346,7 @@ namespace Security tls, }; - KeyEvent(KeyType ty, std::string n, int generation, Triggered triggered = Triggered::unknown) + KeyEvent(KeyType ty, const std::string &n, int generation, Triggered triggered = Triggered::unknown) { set_key_type(ty); set_new(n); @@ -388,7 +389,7 @@ namespace Security class KeyUpdated : public KeyEvent { public: - KeyUpdated(KeyType ty, std::string n, int generation, Triggered triggered = KeyEvent::Triggered::unknown) + KeyUpdated(KeyType ty, const std::string &n, int generation, Triggered triggered = KeyEvent::Triggered::unknown) : KeyEvent(ty, n, generation, triggered) { } @@ -403,7 +404,7 @@ namespace Security class KeyRetired : public KeyEvent { public: - KeyRetired(KeyType ty, std::string n, int generation, Triggered triggered = KeyEvent::Triggered::unknown) + KeyRetired(KeyType ty, const std::string &n, int generation, Triggered triggered = KeyEvent::Triggered::unknown) : KeyEvent(ty, n, generation, triggered) { } @@ -495,7 +496,7 @@ namespace Transport cc_bandwidth_probe, // needed for some CCs to figure out bandwidth allocations when there are no normal sends }; - PacketEvent(PacketType type, PacketHeader h, Triggered tr = Triggered::unknown) + PacketEvent(const PacketType &type, PacketHeader h, Triggered tr = Triggered::unknown) { set_packet_type(type).set_header(h).set_trigger(tr); } @@ -543,7 +544,7 @@ namespace Transport class PacketSent : public PacketEvent { public: - PacketSent(PacketType type, PacketHeader h, Triggered tr = Triggered::unknown) : PacketEvent(type, h, tr) {} + PacketSent(const PacketType &type, const PacketHeader &h, Triggered tr = Triggered::unknown) : PacketEvent(type, h, tr) {} std::string event() const override { @@ -554,7 +555,7 @@ namespace Transport class PacketReceived : public PacketEvent { public: - PacketReceived(PacketType type, PacketHeader h, Triggered tr = Triggered::unknown) : PacketEvent(type, h, tr) {} + PacketReceived(const PacketType &type, const PacketHeader &h, Triggered tr = Triggered::unknown) : PacketEvent(type, h, tr) {} std::string event() const override { diff --git a/iocore/net/quic/qlog/QLogFrame.h b/iocore/net/quic/qlog/QLogFrame.h index be56351a1ee..6dfb035b813 100644 --- a/iocore/net/quic/qlog/QLogFrame.h +++ b/iocore/net/quic/qlog/QLogFrame.h @@ -171,7 +171,7 @@ namespace Frame }; struct MaxDataFrame : public QLogFrame { - MaxDataFrame(const QUICMaxDataFrame &frame) : QLogFrame(frame.type()) { maximum = std::to_string(frame.maximum_data()); } + MaxDataFrame(const QUICMaxDataFrame &frame) : QLogFrame(frame.type()), maximum(std::to_string(frame.maximum_data())) {} void encode(YAML::Node &) override; std::string maximum; @@ -234,9 +234,9 @@ namespace Frame }; struct NewConnectionIDFrame : public QLogFrame { - NewConnectionIDFrame(const QUICNewConnectionIdFrame &frame) : QLogFrame(frame.type()) + NewConnectionIDFrame(const QUICNewConnectionIdFrame &frame) + : QLogFrame(frame.type()), sequence_number(std::to_string(frame.sequence())) { - sequence_number = std::to_string(frame.sequence()); retire_prior_to = std::to_string(frame.retire_prior_to()); connection_id = frame.connection_id().hex(); stateless_reset_token = QUICBase::to_hex(frame.stateless_reset_token().buf(), QUICStatelessResetToken::LEN); @@ -249,37 +249,37 @@ namespace Frame }; struct RetireConnectionIDFrame : public QLogFrame { - RetireConnectionIDFrame(const QUICRetireConnectionIdFrame &frame) : QLogFrame(frame.type()) + RetireConnectionIDFrame(const QUICRetireConnectionIdFrame &frame) + : QLogFrame(frame.type()), sequence_number(std::to_string(frame.seq_num())) { - sequence_number = std::to_string(frame.seq_num()); } void encode(YAML::Node &) override; std::string sequence_number; }; struct PathChallengeFrame : public QLogFrame { - PathChallengeFrame(const QUICPathChallengeFrame &frame) : QLogFrame(frame.type()) + PathChallengeFrame(const QUICPathChallengeFrame &frame) + : QLogFrame(frame.type()), data(QUICBase::to_hex(frame.data(), QUICPathChallengeFrame::DATA_LEN)) { - data = QUICBase::to_hex(frame.data(), QUICPathChallengeFrame::DATA_LEN); } void encode(YAML::Node &) override; std::string data; }; struct PathResponseFrame : public QLogFrame { - PathResponseFrame(const QUICPathResponseFrame &frame) : QLogFrame(frame.type()) + PathResponseFrame(const QUICPathResponseFrame &frame) + : QLogFrame(frame.type()), data(QUICBase::to_hex(frame.data(), QUICPathChallengeFrame::DATA_LEN)) { - data = QUICBase::to_hex(frame.data(), QUICPathChallengeFrame::DATA_LEN); } void encode(YAML::Node &) override; std::string data; }; struct ConnectionCloseFrame : public QLogFrame { - ConnectionCloseFrame(const QUICConnectionCloseFrame &frame, bool app = false) : QLogFrame(frame.type()) + ConnectionCloseFrame(const QUICConnectionCloseFrame &frame, bool app = false) + : QLogFrame(frame.type()), error_space(app ? "application" : "transport") { - error_space = app ? "application" : "transport"; - error_code = frame.error_code(); + error_code = frame.error_code(); // FIXME raw_error_code = error_code; reason = frame.reason_phrase(); diff --git a/proxy/http3/QPACK.cc b/proxy/http3/QPACK.cc index 6af4a16e928..21702148176 100644 --- a/proxy/http3/QPACK.cc +++ b/proxy/http3/QPACK.cc @@ -1397,7 +1397,7 @@ QPACK::DynamicTable::unref_entry(uint16_t index) } uint16_t -QPACK::DynamicTable::largest_index() +QPACK::DynamicTable::largest_index() const { return this->_entries_inserted; } @@ -1802,7 +1802,8 @@ QPACK::DynamicTableStorage::~DynamicTableStorage() } void -QPACK::DynamicTableStorage::read(uint16_t offset, const char **name, uint16_t name_len, const char **value, uint16_t value_len) +QPACK::DynamicTableStorage::read(uint16_t offset, const char **name, uint16_t name_len, const char **value, + uint16_t value_len) const { *name = reinterpret_cast(this->_data + offset); *value = reinterpret_cast(this->_data + offset + name_len); diff --git a/proxy/http3/QPACK.h b/proxy/http3/QPACK.h index 9b40c17cb47..e81b4ab0673 100644 --- a/proxy/http3/QPACK.h +++ b/proxy/http3/QPACK.h @@ -112,7 +112,7 @@ class QPACK : public QUICApplication public: DynamicTableStorage(uint16_t size); ~DynamicTableStorage(); - void read(uint16_t offset, const char **name, uint16_t name_len, const char **value, uint16_t value_len); + void read(uint16_t offset, const char **name, uint16_t name_len, const char **value, uint16_t value_len) const; uint16_t write(const char *name, uint16_t name_len, const char *value, uint16_t value_len); void erase(uint16_t name_len, uint16_t value_len); @@ -139,7 +139,7 @@ class QPACK : public QUICApplication void update_size(uint16_t max_size); void ref_entry(uint16_t index); void unref_entry(uint16_t index); - uint16_t largest_index(); + uint16_t largest_index() const; private: uint16_t _available = 0; @@ -169,7 +169,7 @@ class QPACK : public QUICApplication } uint16_t - largest_reference() + largest_reference() const { return this->_largest_reference; } @@ -187,19 +187,19 @@ class QPACK : public QUICApplication } uint64_t - stream_id() + stream_id() const { return this->_stream_id; } const uint8_t * - header_block() + header_block() const { return this->_header_block; } size_t - header_block_len() + header_block_len() const { return this->_header_block_len; }