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 QUICHE_EXPORT 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 QUICHE_EXPORT std::ostream& operator<<(std::ostream& os, 26 const QuicRstStreamFrame& r); 27 28 bool operator==(const QuicRstStreamFrame& rhs) const; 29 bool operator!=(const QuicRstStreamFrame& rhs) const; 30 31 // A unique identifier of this control frame. 0 when this frame is received, 32 // and non-zero when sent. 33 QuicControlFrameId control_frame_id = kInvalidControlFrameId; 34 35 QuicStreamId stream_id = 0; 36 37 // When using Google QUIC: the RST_STREAM error code on the wire. 38 // When using IETF QUIC: for an outgoing RESET_STREAM frame, the error code 39 // generated by the application that determines |ietf_error_code| to be sent 40 // on the wire; for an incoming RESET_STREAM frame, the error code inferred 41 // from the |ietf_error_code| received on the wire. 42 QuicRstStreamErrorCode error_code = QUIC_STREAM_NO_ERROR; 43 44 // Application error code of RESET_STREAM frame. Used for IETF QUIC only. 45 uint64_t ietf_error_code = 0; 46 47 // Used to update flow control windows. On termination of a stream, both 48 // endpoints must inform the peer of the number of bytes they have sent on 49 // that stream. This can be done through normal termination (data packet with 50 // FIN) or through a RST. 51 QuicStreamOffset byte_offset = 0; 52 53 // Returns a tuple of both |error_code| and |ietf_error_code|. errorQuicRstStreamFrame54 QuicResetStreamError error() const { 55 return QuicResetStreamError(error_code, ietf_error_code); 56 } 57 }; 58 59 } // namespace quic 60 61 #endif // QUICHE_QUIC_CORE_FRAMES_QUIC_RST_STREAM_FRAME_H_ 62