xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/core/frames/quic_stop_sending_frame.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2018 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_STOP_SENDING_FRAME_H_
6 #define QUICHE_QUIC_CORE_FRAMES_QUIC_STOP_SENDING_FRAME_H_
7 
8 #include <ostream>
9 
10 #include "quiche/quic/core/frames/quic_inlined_frame.h"
11 #include "quiche/quic/core/quic_constants.h"
12 #include "quiche/quic/core/quic_error_codes.h"
13 #include "quiche/quic/core/quic_types.h"
14 
15 namespace quic {
16 
17 struct QUICHE_EXPORT QuicStopSendingFrame
18     : public QuicInlinedFrame<QuicStopSendingFrame> {
19   QuicStopSendingFrame();
20   QuicStopSendingFrame(QuicControlFrameId control_frame_id,
21                        QuicStreamId stream_id,
22                        QuicRstStreamErrorCode error_code);
23   QuicStopSendingFrame(QuicControlFrameId control_frame_id,
24                        QuicStreamId stream_id, QuicResetStreamError error);
25 
26   friend QUICHE_EXPORT std::ostream& operator<<(
27       std::ostream& os, const QuicStopSendingFrame& frame);
28 
29   bool operator==(const QuicStopSendingFrame& rhs) const;
30   bool operator!=(const QuicStopSendingFrame& rhs) const;
31 
32   QuicFrameType type;
33 
34   // A unique identifier of this control frame. 0 when this frame is received,
35   // and non-zero when sent.
36   QuicControlFrameId control_frame_id = kInvalidControlFrameId;
37   QuicStreamId stream_id = 0;
38 
39   // For an outgoing frame, the error code generated by the application that
40   // determines |ietf_error_code| to be sent on the wire; for an incoming frame,
41   // the error code inferred from |ietf_error_code| received on the wire.
42   QuicRstStreamErrorCode error_code = QUIC_STREAM_NO_ERROR;
43 
44   // On-the-wire application error code of the frame.
45   uint64_t ietf_error_code = 0;
46 
47   // Returns a tuple of both |error_code| and |ietf_error_code|.
errorQuicStopSendingFrame48   QuicResetStreamError error() const {
49     return QuicResetStreamError(error_code, ietf_error_code);
50   }
51 };
52 
53 }  // namespace quic
54 
55 #endif  // QUICHE_QUIC_CORE_FRAMES_QUIC_STOP_SENDING_FRAME_H_
56