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 #include "quiche/quic/core/frames/quic_rst_stream_frame.h"
6
7 #include "quiche/quic/core/quic_error_codes.h"
8
9 namespace quic {
10
QuicRstStreamFrame(QuicControlFrameId control_frame_id,QuicStreamId stream_id,QuicRstStreamErrorCode error_code,QuicStreamOffset bytes_written)11 QuicRstStreamFrame::QuicRstStreamFrame(QuicControlFrameId control_frame_id,
12 QuicStreamId stream_id,
13 QuicRstStreamErrorCode error_code,
14 QuicStreamOffset bytes_written)
15 : control_frame_id(control_frame_id),
16 stream_id(stream_id),
17 error_code(error_code),
18 ietf_error_code(RstStreamErrorCodeToIetfResetStreamErrorCode(error_code)),
19 byte_offset(bytes_written) {}
20
QuicRstStreamFrame(QuicControlFrameId control_frame_id,QuicStreamId stream_id,QuicResetStreamError error,QuicStreamOffset bytes_written)21 QuicRstStreamFrame::QuicRstStreamFrame(QuicControlFrameId control_frame_id,
22 QuicStreamId stream_id,
23 QuicResetStreamError error,
24 QuicStreamOffset bytes_written)
25 : control_frame_id(control_frame_id),
26 stream_id(stream_id),
27 error_code(error.internal_code()),
28 ietf_error_code(error.ietf_application_code()),
29 byte_offset(bytes_written) {}
30
operator <<(std::ostream & os,const QuicRstStreamFrame & rst_frame)31 std::ostream& operator<<(std::ostream& os,
32 const QuicRstStreamFrame& rst_frame) {
33 os << "{ control_frame_id: " << rst_frame.control_frame_id
34 << ", stream_id: " << rst_frame.stream_id
35 << ", byte_offset: " << rst_frame.byte_offset
36 << ", error_code: " << rst_frame.error_code
37 << ", ietf_error_code: " << rst_frame.ietf_error_code << " }\n";
38 return os;
39 }
40
operator ==(const QuicRstStreamFrame & rhs) const41 bool QuicRstStreamFrame::operator==(const QuicRstStreamFrame& rhs) const {
42 return control_frame_id == rhs.control_frame_id &&
43 stream_id == rhs.stream_id && byte_offset == rhs.byte_offset &&
44 error_code == rhs.error_code && ietf_error_code == rhs.ietf_error_code;
45 }
46
operator !=(const QuicRstStreamFrame & rhs) const47 bool QuicRstStreamFrame::operator!=(const QuicRstStreamFrame& rhs) const {
48 return !(*this == rhs);
49 }
50
51 } // namespace quic
52