blob: 33ecedc1fe867b6134438066c09d86e1c3b7eadd [file] [log] [blame] [edit]
// 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.
#ifndef QUICHE_QUIC_CORE_CONNECTION_ID_GENERATOR_H_
#define QUICHE_QUIC_CORE_CONNECTION_ID_GENERATOR_H_
#include "quiche/quic/core/quic_connection_id.h"
#include "quiche/quic/core/quic_versions.h"
namespace quic {
class QUICHE_EXPORT ConnectionIdGeneratorInterface {
// Interface which is responsible for generating new connection IDs from an
// existing connection ID.
public:
// Generate a new connection ID for a given connection ID. Returns the new
// connection ID. If it cannot be generated for some reason, returns
// empty.
virtual std::optional<QuicConnectionId> GenerateNextConnectionId(
const QuicConnectionId& original) = 0;
// Consider the client-generated server connection ID in the quic handshake
// and consider replacing it. Returns empty if not replaced.
virtual std::optional<QuicConnectionId> MaybeReplaceConnectionId(
const QuicConnectionId& original, const ParsedQuicVersion& version) = 0;
// Returns the length of a connection ID generated by this generator with the
// specified first byte.
virtual uint8_t ConnectionIdLength(uint8_t first_byte) const = 0;
virtual ~ConnectionIdGeneratorInterface() = default;
};
} // namespace quic
#endif // QUICHE_QUIC_CORE_CONNECTION_ID_GENERATOR_H_