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_CONNECTION_CLOSE_FRAME_H_ 6 #define QUICHE_QUIC_CORE_FRAMES_QUIC_CONNECTION_CLOSE_FRAME_H_ 7 8 #include <ostream> 9 #include <string> 10 11 #include "quiche/quic/core/quic_error_codes.h" 12 #include "quiche/quic/core/quic_types.h" 13 #include "quiche/quic/core/quic_versions.h" 14 #include "quiche/quic/platform/api/quic_export.h" 15 16 namespace quic { 17 18 struct QUICHE_EXPORT QuicConnectionCloseFrame { 19 QuicConnectionCloseFrame() = default; 20 21 // Builds a connection close frame based on the transport version 22 // and the mapping of error_code. THIS IS THE PREFERRED C'TOR 23 // TO USE IF YOU NEED TO CREATE A CONNECTION-CLOSE-FRAME AND 24 // HAVE IT BE CORRECT FOR THE VERSION AND CODE MAPPINGS. 25 // |ietf_error| may optionally be be used to directly specify the wire 26 // error code. Otherwise if |ietf_error| is NO_IETF_QUIC_ERROR, the 27 // QuicErrorCodeToTransportErrorCode mapping of |error_code| will be used. 28 QuicConnectionCloseFrame(QuicTransportVersion transport_version, 29 QuicErrorCode error_code, 30 QuicIetfTransportErrorCodes ietf_error, 31 std::string error_phrase, 32 uint64_t transport_close_frame_type); 33 34 friend QUICHE_EXPORT std::ostream& operator<<( 35 std::ostream& os, const QuicConnectionCloseFrame& c); 36 37 // Indicates whether the the frame is a Google QUIC CONNECTION_CLOSE frame, 38 // an IETF QUIC CONNECTION_CLOSE frame with transport error code, 39 // or an IETF QUIC CONNECTION_CLOSE frame with application error code. 40 QuicConnectionCloseType close_type = GOOGLE_QUIC_CONNECTION_CLOSE; 41 42 // The error code on the wire. For Google QUIC frames, this has the same 43 // value as |quic_error_code|. 44 uint64_t wire_error_code = QUIC_NO_ERROR; 45 46 // The underlying error. For Google QUIC frames, this has the same value as 47 // |wire_error_code|. For sent IETF QUIC frames, this is the error that 48 // triggered the closure of the connection. For received IETF QUIC frames, 49 // this is parsed from the Reason Phrase field of the CONNECTION_CLOSE frame, 50 // or QUIC_IETF_GQUIC_ERROR_MISSING. 51 QuicErrorCode quic_error_code = QUIC_NO_ERROR; 52 53 // String with additional error details. |quic_error_code| and a colon will be 54 // prepended to the error details when sending IETF QUIC frames, and parsed 55 // into |quic_error_code| upon receipt, when present. 56 std::string error_details; 57 58 // The frame type present in the IETF transport connection close frame. 59 // Not populated for the Google QUIC or application connection close frames. 60 // Contains the type of frame that triggered the connection close. Made a 61 // uint64, as opposed to the QuicIetfFrameType, to support possible 62 // extensions as well as reporting invalid frame types received from the peer. 63 uint64_t transport_close_frame_type = 0; 64 }; 65 66 } // namespace quic 67 68 #endif // QUICHE_QUIC_CORE_FRAMES_QUIC_CONNECTION_CLOSE_FRAME_H_ 69