xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/core/frames/quic_reset_stream_at_frame.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2024 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_FRAMES_QUIC_RESET_STREAM_AT_FRAME_H_
6 #define QUICHE_QUIC_CORE_FRAMES_QUIC_RESET_STREAM_AT_FRAME_H_
7 
8 #include <cstdint>
9 #include <ostream>
10 
11 #include "quiche/quic/core/quic_constants.h"
12 #include "quiche/quic/core/quic_types.h"
13 #include "quiche/common/platform/api/quiche_export.h"
14 
15 namespace quic {
16 
17 // RESET_STREAM_AT allows a QUIC application to reset a stream, but only after
18 // the receiver consumes data up to a certain point. Defined in
19 // <https://datatracker.ietf.org/doc/draft-ietf-quic-reliable-stream-reset/>.
20 struct QUICHE_EXPORT QuicResetStreamAtFrame {
21   QuicResetStreamAtFrame() = default;
22   QuicResetStreamAtFrame(QuicControlFrameId control_frame_id,
23                          QuicStreamId stream_id, uint64_t error,
24                          QuicStreamOffset final_offset,
25                          QuicStreamOffset reliable_offset);
26 
27   friend QUICHE_EXPORT std::ostream& operator<<(
28       std::ostream& os, const QuicResetStreamAtFrame& frame);
29 
30   bool operator==(const QuicResetStreamAtFrame& rhs) const;
31   bool operator!=(const QuicResetStreamAtFrame& rhs) const;
32 
33   // A unique identifier of this control frame. 0 when this frame is received,
34   // and non-zero when sent.
35   QuicControlFrameId control_frame_id = kInvalidControlFrameId;
36 
37   QuicStreamId stream_id = 0;
38   uint64_t error = 0;
39 
40   // The total number of bytes ever sent on the stream; used for flow control.
41   QuicStreamOffset final_offset = 0;
42   // The RESET_STREAM is active only after the application reads up to
43   // `reliable_offset` bytes.
44   QuicStreamOffset reliable_offset = 0;
45 };
46 
47 }  // namespace quic
48 
49 #endif  // QUICHE_QUIC_CORE_FRAMES_QUIC_RESET_STREAM_AT_FRAME_H_
50