#include "quiche/quic/core/quic_connection_id_manager.h"
#include <algorithm>
#include <cstdio>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "quiche/quic/core/quic_clock.h"
#include "quiche/quic/core/quic_connection_id.h"
#include "quiche/quic/core/quic_error_codes.h"
#include "quiche/quic/core/quic_utils.h"
#include "quiche/quic/platform/api/quic_flag_utils.h"
#include "quiche/quic/platform/api/quic_flags.h"
#include "quiche/common/platform/api/quiche_logging.h"
namespace quic {
QuicConnectionIdData::QuicConnectionIdData(
const QuicConnectionId& connection_id, uint64_t sequence_number,
const StatelessResetToken& stateless_reset_token)
: … { … }
namespace {
class RetirePeerIssuedConnectionIdAlarm
: public QuicAlarm::DelegateWithContext { … };
std::vector<QuicConnectionIdData>::const_iterator FindConnectionIdData(
const std::vector<QuicConnectionIdData>& cid_data_vector,
const QuicConnectionId& cid) { … }
std::vector<QuicConnectionIdData>::iterator FindConnectionIdData(
std::vector<QuicConnectionIdData>* cid_data_vector,
const QuicConnectionId& cid) { … }
}
QuicPeerIssuedConnectionIdManager::QuicPeerIssuedConnectionIdManager(
size_t active_connection_id_limit,
const QuicConnectionId& initial_peer_issued_connection_id,
const QuicClock* clock, QuicAlarmFactory* alarm_factory,
QuicConnectionIdManagerVisitorInterface* visitor,
QuicConnectionContext* context)
: … { … }
QuicPeerIssuedConnectionIdManager::~QuicPeerIssuedConnectionIdManager() { … }
bool QuicPeerIssuedConnectionIdManager::IsConnectionIdNew(
const QuicNewConnectionIdFrame& frame) { … }
void QuicPeerIssuedConnectionIdManager::PrepareToRetireConnectionIdPriorTo(
uint64_t retire_prior_to,
std::vector<QuicConnectionIdData>* cid_data_vector) { … }
QuicErrorCode QuicPeerIssuedConnectionIdManager::OnNewConnectionIdFrame(
const QuicNewConnectionIdFrame& frame, std::string* error_detail,
bool* is_duplicate_frame) { … }
const QuicConnectionIdData*
QuicPeerIssuedConnectionIdManager::ConsumeOneUnusedConnectionId() { … }
void QuicPeerIssuedConnectionIdManager::PrepareToRetireActiveConnectionId(
const QuicConnectionId& cid) { … }
void QuicPeerIssuedConnectionIdManager::MaybeRetireUnusedConnectionIds(
const std::vector<QuicConnectionId>& active_connection_ids_on_path) { … }
bool QuicPeerIssuedConnectionIdManager::IsConnectionIdActive(
const QuicConnectionId& cid) const { … }
std::vector<uint64_t> QuicPeerIssuedConnectionIdManager::
ConsumeToBeRetiredConnectionIdSequenceNumbers() { … }
void QuicPeerIssuedConnectionIdManager::ReplaceConnectionId(
const QuicConnectionId& old_connection_id,
const QuicConnectionId& new_connection_id) { … }
namespace {
class RetireSelfIssuedConnectionIdAlarmDelegate
: public QuicAlarm::DelegateWithContext { … };
}
QuicSelfIssuedConnectionIdManager::QuicSelfIssuedConnectionIdManager(
size_t active_connection_id_limit,
const QuicConnectionId& initial_connection_id, const QuicClock* clock,
QuicAlarmFactory* alarm_factory,
QuicConnectionIdManagerVisitorInterface* visitor,
QuicConnectionContext* context, ConnectionIdGeneratorInterface& generator)
: … { … }
QuicSelfIssuedConnectionIdManager::~QuicSelfIssuedConnectionIdManager() { … }
std::optional<QuicNewConnectionIdFrame>
QuicSelfIssuedConnectionIdManager::MaybeIssueNewConnectionId() { … }
std::optional<QuicNewConnectionIdFrame> QuicSelfIssuedConnectionIdManager::
MaybeIssueNewConnectionIdForPreferredAddress() { … }
QuicErrorCode QuicSelfIssuedConnectionIdManager::OnRetireConnectionIdFrame(
const QuicRetireConnectionIdFrame& frame, QuicTime::Delta pto_delay,
std::string* error_detail) { … }
std::vector<QuicConnectionId>
QuicSelfIssuedConnectionIdManager::GetUnretiredConnectionIds() const { … }
QuicConnectionId QuicSelfIssuedConnectionIdManager::GetOneActiveConnectionId()
const { … }
void QuicSelfIssuedConnectionIdManager::RetireConnectionId() { … }
void QuicSelfIssuedConnectionIdManager::MaybeSendNewConnectionIds() { … }
bool QuicSelfIssuedConnectionIdManager::HasConnectionIdToConsume() const { … }
std::optional<QuicConnectionId>
QuicSelfIssuedConnectionIdManager::ConsumeOneConnectionId() { … }
bool QuicSelfIssuedConnectionIdManager::IsConnectionIdInUse(
const QuicConnectionId& cid) const { … }
}