1 // Copyright (c) 2016 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_RST_STREAM_FRAME_H_ 6 #define QUICHE_QUIC_CORE_FRAMES_QUIC_RST_STREAM_FRAME_H_ 7 8 #include <ostream> 9 10 #include "quiche/quic/core/quic_constants.h" 11 #include "quiche/quic/core/quic_error_codes.h" 12 #include "quiche/quic/core/quic_types.h" 13 14 namespace quic { 15 16 struct QUIC_EXPORT_PRIVATE QuicRstStreamFrame { 17 QuicRstStreamFrame() = default; 18 QuicRstStreamFrame(QuicControlFrameId control_frame_id, 19 QuicStreamId stream_id, QuicRstStreamErrorCode error_code, 20 QuicStreamOffset bytes_written); 21 QuicRstStreamFrame(QuicControlFrameId control_frame_id, 22 QuicStreamId stream_id, QuicResetStreamError error, 23 QuicStreamOffset bytes_written); 24 25 friend QUIC_EXPORT_PRIVATE std::ostream& operator<<( 26 std::ostream& os, const QuicRstStreamFrame& r); 27 28 // A unique identifier of this control frame. 0 when this frame is received, 29 // and non-zero when sent. 30 QuicControlFrameId control_frame_id = kInvalidControlFrameId; 31 32 QuicStreamId stream_id = 0; 33 34 // When using Google QUIC: the RST_STREAM error code on the wire. 35 // When using IETF QUIC: for an outgoing RESET_STREAM frame, the error code 36 // generated by the application that determines |ietf_error_code| to be sent 37 // on the wire; for an incoming RESET_STREAM frame, the error code inferred 38 // from the |ietf_error_code| received on the wire. 39 QuicRstStreamErrorCode error_code = QUIC_STREAM_NO_ERROR; 40 41 // Application error code of RESET_STREAM frame. Used for IETF QUIC only. 42 uint64_t ietf_error_code = 0; 43 44 // Used to update flow control windows. On termination of a stream, both 45 // endpoints must inform the peer of the number of bytes they have sent on 46 // that stream. This can be done through normal termination (data packet with 47 // FIN) or through a RST. 48 QuicStreamOffset byte_offset = 0; 49 50 // Returns a tuple of both |error_code| and |ietf_error_code|. errorQuicRstStreamFrame51 QuicResetStreamError error() const { 52 return QuicResetStreamError(error_code, ietf_error_code); 53 } 54 }; 55 56 } // namespace quic 57 58 #endif // QUICHE_QUIC_CORE_FRAMES_QUIC_RST_STREAM_FRAME_H_ 59