blob: fc8f8e4672958acf91406248558133c9370c5f61 [file] [log] [blame]
// Copyright (c) 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// A Connection ID generator that generates deterministic connection IDs for
// QUIC servers.
#include "quiche/quic/core/connection_id_generator.h"
namespace quic {
// Generates connection IDs deterministically from the provided original
// connection ID.
class QUICHE_EXPORT DeterministicConnectionIdGenerator
: public ConnectionIdGeneratorInterface {
DeterministicConnectionIdGenerator(uint8_t expected_connection_id_length);
// Hashes |original| to create a new connection ID.
std::optional<QuicConnectionId> GenerateNextConnectionId(
const QuicConnectionId& original) override;
// Replace the connection ID if and only if |original| is not of the expected
// length.
std::optional<QuicConnectionId> MaybeReplaceConnectionId(
const QuicConnectionId& original,
const ParsedQuicVersion& version) override;
uint8_t ConnectionIdLength(uint8_t /*first_byte*/) const override {
return expected_connection_id_length_;
const uint8_t expected_connection_id_length_;
} // namespace quic