chromium/net/third_party/quiche/src/quiche/quic/core/quic_framer.h

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef QUICHE_QUIC_CORE_QUIC_FRAMER_H_
#define QUICHE_QUIC_CORE_QUIC_FRAMER_H_

#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>

#include "absl/strings/string_view.h"
#include "quiche/quic/core/connection_id_generator.h"
#include "quiche/quic/core/crypto/quic_decrypter.h"
#include "quiche/quic/core/crypto/quic_encrypter.h"
#include "quiche/quic/core/crypto/quic_random.h"
#include "quiche/quic/core/frames/quic_reset_stream_at_frame.h"
#include "quiche/quic/core/quic_connection_id.h"
#include "quiche/quic/core/quic_packets.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/platform/api/quic_export.h"

namespace quic {

namespace test {
class QuicFramerPeer;
}  // namespace test

class QuicDataReader;
class QuicDataWriter;
class QuicFramer;
class QuicStreamFrameDataProducer;

// Number of bytes reserved for the frame type preceding each frame.
inline constexpr size_t kQuicFrameTypeSize =;
// Number of bytes reserved for error code.
inline constexpr size_t kQuicErrorCodeSize =;
// Number of bytes reserved to denote the length of error details field.
inline constexpr size_t kQuicErrorDetailsLengthSize =;

// Maximum number of bytes reserved for stream id.
inline constexpr size_t kQuicMaxStreamIdSize =;
// Maximum number of bytes reserved for byte offset in stream frame.
inline constexpr size_t kQuicMaxStreamOffsetSize =;
// Number of bytes reserved to store payload length in stream frame.
inline constexpr size_t kQuicStreamPayloadLengthSize =;
// Number of bytes to reserve for IQ Error codes (for the Connection Close,
// Application Close, and Reset Stream frames).
inline constexpr size_t kQuicIetfQuicErrorCodeSize =;
// Minimum size of the IETF QUIC Error Phrase's length field
inline constexpr size_t kIetfQuicMinErrorPhraseLengthSize =;

// Size in bytes reserved for the delta time of the largest observed
// packet number in ack frames.
inline constexpr size_t kQuicDeltaTimeLargestObservedSize =;
// Size in bytes reserved for the number of received packets with timestamps.
inline constexpr size_t kQuicNumTimestampsSize =;
// Size in bytes reserved for the number of missing packets in ack frames.
inline constexpr size_t kNumberOfNackRangesSize =;
// Size in bytes reserved for the number of ack blocks in ack frames.
inline constexpr size_t kNumberOfAckBlocksSize =;
// Maximum number of missing packet ranges that can fit within an ack frame.
inline constexpr size_t kMaxNackRanges =;
// Maximum number of ack blocks that can fit within an ack frame.
inline constexpr size_t kMaxAckBlocks =;

// This class receives callbacks from the framer when packets
// are processed.
class QUICHE_EXPORT QuicFramerVisitorInterface {};

// Class for parsing and constructing QUIC packets.  It has a
// QuicFramerVisitorInterface that is called when packets are parsed.
class QUICHE_EXPORT QuicFramer {};

// Look for and parse the error code from the "<quic_error_code>:" text that
// may be present at the start of the CONNECTION_CLOSE error details string.
// This text, inserted by the peer if it's using Google's QUIC implementation,
// contains additional error information that narrows down the exact error. The
// extracted error code and (possibly updated) error_details string are returned
// in |*frame|. If an error code is not found in the error details, then
// frame->quic_error_code is set to
// QuicErrorCode::QUIC_IETF_GQUIC_ERROR_MISSING.  If there is an error code in
// the string then it is removed from the string.
QUICHE_EXPORT void MaybeExtractQuicErrorCode(QuicConnectionCloseFrame* frame);

}  // namespace quic

#endif  // QUICHE_QUIC_CORE_QUIC_FRAMER_H_