xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/core/connection_id_generator.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2022 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef QUICHE_QUIC_CORE_CONNECTION_ID_GENERATOR_H_
6 #define QUICHE_QUIC_CORE_CONNECTION_ID_GENERATOR_H_
7 
8 #include "quiche/quic/core/quic_connection_id.h"
9 #include "quiche/quic/core/quic_versions.h"
10 
11 namespace quic {
12 
13 class QUICHE_EXPORT ConnectionIdGeneratorInterface {
14   // Interface which is responsible for generating new connection IDs from an
15   // existing connection ID.
16  public:
17   // Generate a new connection ID for a given connection ID. Returns the new
18   // connection ID. If it cannot be generated for some reason, returns
19   // empty.
20   virtual std::optional<QuicConnectionId> GenerateNextConnectionId(
21       const QuicConnectionId& original) = 0;
22   // Consider the client-generated server connection ID in the quic handshake
23   // and consider replacing it. Returns empty if not replaced.
24   virtual std::optional<QuicConnectionId> MaybeReplaceConnectionId(
25       const QuicConnectionId& original, const ParsedQuicVersion& version) = 0;
26   // Returns the length of a connection ID generated by this generator with the
27   // specified first byte.
28   virtual uint8_t ConnectionIdLength(uint8_t first_byte) const = 0;
29   virtual ~ConnectionIdGeneratorInterface() = default;
30 };
31 
32 }  // namespace quic
33 
34 #endif  // QUICHE_QUIC_CORE_CONNECTION_ID_GENERATOR_H_
35