chromium/net/third_party/quiche/src/quiche/http2/core/http2_frame_decoder_adapter.cc

// Copyright 2016 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.

#include "quiche/http2/core/http2_frame_decoder_adapter.h"

// Logging policy: If an error in the input is detected, QUICHE_VLOG(n) is used
// so that the option exists to debug the situation. Otherwise, this code mostly
// uses QUICHE_DVLOG so that the logging does not slow down production code when
// things are working OK.

#include <stddef.h>

#include <cstdint>
#include <cstring>
#include <memory>
#include <string>

#include "absl/strings/string_view.h"
#include "quiche/http2/core/spdy_alt_svc_wire_format.h"
#include "quiche/http2/core/spdy_headers_handler_interface.h"
#include "quiche/http2/core/spdy_protocol.h"
#include "quiche/http2/decoder/decode_buffer.h"
#include "quiche/http2/decoder/decode_status.h"
#include "quiche/http2/decoder/http2_frame_decoder.h"
#include "quiche/http2/hpack/decoder/hpack_decoding_error.h"
#include "quiche/http2/hpack/hpack_header_table.h"
#include "quiche/http2/http2_constants.h"
#include "quiche/http2/http2_structures.h"
#include "quiche/common/platform/api/quiche_bug_tracker.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/quiche_endian.h"
#include "quiche/spdy/core/hpack/hpack_decoder_adapter.h"

ExtensionVisitorInterface;
HpackDecoderAdapter;
HpackHeaderTable;
ParseErrorCode;
ParseFrameType;
SpdyAltSvcWireFormat;
SpdyErrorCode;
SpdyFramerDebugVisitorInterface;
SpdyFramerVisitorInterface;
SpdyFrameType;
SpdyHeadersHandlerInterface;
SpdyKnownSettingsId;
SpdySettingsId;

namespace http2 {
namespace {

const bool kHasPriorityFields =;
const bool kNotHasPriorityFields =;

bool IsPaddable(Http2FrameType type) {}

SpdyFrameType ToSpdyFrameType(Http2FrameType type) {}

uint64_t ToSpdyPingId(const Http2PingFields& ping) {}

// Overwrites the fields of the header with invalid values, for the purpose
// of identifying reading of unset fields. Only takes effect for debug builds.
// In Address Sanitizer builds, it also marks the fields as un-readable.
#ifndef NDEBUG
void CorruptFrameHeader(Http2FrameHeader* header) {}
#else
void CorruptFrameHeader(Http2FrameHeader* /*header*/) {}
#endif

Http2DecoderAdapter::SpdyFramerError HpackDecodingErrorToSpdyFramerError(
    HpackDecodingError error) {}

}  // namespace

const char* Http2DecoderAdapter::StateToString(int state) {}

const char* Http2DecoderAdapter::SpdyFramerErrorToString(
    SpdyFramerError spdy_framer_error) {}

Http2DecoderAdapter::Http2DecoderAdapter() :{}

Http2DecoderAdapter::~Http2DecoderAdapter() = default;

void Http2DecoderAdapter::set_visitor(SpdyFramerVisitorInterface* visitor) {}

void Http2DecoderAdapter::set_debug_visitor(
    SpdyFramerDebugVisitorInterface* debug_visitor) {}

void Http2DecoderAdapter::set_extension_visitor(
    ExtensionVisitorInterface* visitor) {}

size_t Http2DecoderAdapter::ProcessInput(const char* data, size_t len) {}

Http2DecoderAdapter::SpdyState Http2DecoderAdapter::state() const {}

Http2DecoderAdapter::SpdyFramerError Http2DecoderAdapter::spdy_framer_error()
    const {}

bool Http2DecoderAdapter::probable_http_response() const {}

void Http2DecoderAdapter::StopProcessing() {}

void Http2DecoderAdapter::SetMaxFrameSize(size_t max_frame_size) {}

// ===========================================================================
// Implementations of the methods declared by Http2FrameDecoderListener.

// Called once the common frame header has been decoded for any frame.
// This function is largely based on Http2DecoderAdapter::ValidateFrameHeader
// and some parts of Http2DecoderAdapter::ProcessCommonHeader.
bool Http2DecoderAdapter::OnFrameHeader(const Http2FrameHeader& header) {}

void Http2DecoderAdapter::OnDataStart(const Http2FrameHeader& header) {}

void Http2DecoderAdapter::OnDataPayload(const char* data, size_t len) {}

void Http2DecoderAdapter::OnDataEnd() {}

void Http2DecoderAdapter::OnHeadersStart(const Http2FrameHeader& header) {}

void Http2DecoderAdapter::OnHeadersPriority(
    const Http2PriorityFields& priority) {}

void Http2DecoderAdapter::OnHpackFragment(const char* data, size_t len) {}

void Http2DecoderAdapter::OnHeadersEnd() {}

void Http2DecoderAdapter::OnPriorityFrame(const Http2FrameHeader& header,
                                          const Http2PriorityFields& priority) {}

void Http2DecoderAdapter::OnContinuationStart(const Http2FrameHeader& header) {}

void Http2DecoderAdapter::OnContinuationEnd() {}

void Http2DecoderAdapter::OnPadLength(size_t trailing_length) {}

void Http2DecoderAdapter::OnPadding(const char* /*padding*/,
                                    size_t skipped_length) {}

void Http2DecoderAdapter::OnRstStream(const Http2FrameHeader& header,
                                      Http2ErrorCode http2_error_code) {}

void Http2DecoderAdapter::OnSettingsStart(const Http2FrameHeader& header) {}

void Http2DecoderAdapter::OnSetting(const Http2SettingFields& setting_fields) {}

void Http2DecoderAdapter::OnSettingsEnd() {}

void Http2DecoderAdapter::OnSettingsAck(const Http2FrameHeader& header) {}

void Http2DecoderAdapter::OnPushPromiseStart(
    const Http2FrameHeader& header, const Http2PushPromiseFields& promise,
    size_t total_padding_length) {}

void Http2DecoderAdapter::OnPushPromiseEnd() {}

void Http2DecoderAdapter::OnPing(const Http2FrameHeader& header,
                                 const Http2PingFields& ping) {}

void Http2DecoderAdapter::OnPingAck(const Http2FrameHeader& header,
                                    const Http2PingFields& ping) {}

void Http2DecoderAdapter::OnGoAwayStart(const Http2FrameHeader& header,
                                        const Http2GoAwayFields& goaway) {}

void Http2DecoderAdapter::OnGoAwayOpaqueData(const char* data, size_t len) {}

void Http2DecoderAdapter::OnGoAwayEnd() {}

void Http2DecoderAdapter::OnWindowUpdate(const Http2FrameHeader& header,
                                         uint32_t increment) {}

// Per RFC7838, an ALTSVC frame on stream 0 with origin_length == 0, or one on
// a stream other than stream 0 with origin_length != 0 MUST be ignored.  All
// frames are decoded by Http2DecoderAdapter, and it is left to the consumer
// (listener) to implement this behavior.
void Http2DecoderAdapter::OnAltSvcStart(const Http2FrameHeader& header,
                                        size_t origin_length,
                                        size_t value_length) {}

void Http2DecoderAdapter::OnAltSvcOriginData(const char* data, size_t len) {}

// Called when decoding the Alt-Svc-Field-Value of an ALTSVC;
// the field is uninterpreted.
void Http2DecoderAdapter::OnAltSvcValueData(const char* data, size_t len) {}

void Http2DecoderAdapter::OnAltSvcEnd() {}

void Http2DecoderAdapter::OnPriorityUpdateStart(
    const Http2FrameHeader& header,
    const Http2PriorityUpdateFields& priority_update) {}

void Http2DecoderAdapter::OnPriorityUpdatePayload(const char* data,
                                                  size_t len) {}

void Http2DecoderAdapter::OnPriorityUpdateEnd() {}

void Http2DecoderAdapter::OnUnknownStart(const Http2FrameHeader& header) {}

void Http2DecoderAdapter::OnUnknownPayload(const char* data, size_t len) {}

void Http2DecoderAdapter::OnUnknownEnd() {}

void Http2DecoderAdapter::OnPaddingTooLong(const Http2FrameHeader& header,
                                           size_t missing_length) {}

void Http2DecoderAdapter::OnFrameSizeError(const Http2FrameHeader& header) {}

// Decodes the input up to the next frame boundary (i.e. at most one frame),
// stopping early if an error is detected.
size_t Http2DecoderAdapter::ProcessInputFrame(const char* data, size_t len) {}

// After decoding, determine the next SpdyState. Only called if the current
// state is NOT SpdyState::SPDY_ERROR (i.e. if none of the callback methods
// detected an error condition), because otherwise we assume that the callback
// method has set spdy_framer_error_ appropriately.
void Http2DecoderAdapter::DetermineSpdyState(DecodeStatus status) {}

void Http2DecoderAdapter::ResetBetweenFrames() {}

void Http2DecoderAdapter::set_spdy_state(SpdyState v) {}

void Http2DecoderAdapter::SetSpdyErrorAndNotify(SpdyFramerError error,
                                                std::string detailed_error) {}

bool Http2DecoderAdapter::HasError() const {}

const Http2FrameHeader& Http2DecoderAdapter::frame_header() const {}

uint32_t Http2DecoderAdapter::stream_id() const {}

Http2FrameType Http2DecoderAdapter::frame_type() const {}

size_t Http2DecoderAdapter::remaining_total_payload() const {}

bool Http2DecoderAdapter::IsReadingPaddingLength() {}
bool Http2DecoderAdapter::IsSkippingPadding() {}
bool Http2DecoderAdapter::IsDiscardingPayload() {}
// Called from OnXyz or OnXyzStart methods to decide whether it is OK to
// handle the callback.
bool Http2DecoderAdapter::IsOkToStartFrame(const Http2FrameHeader& header) {}

bool Http2DecoderAdapter::HasRequiredStreamId(uint32_t stream_id) {}

bool Http2DecoderAdapter::HasRequiredStreamId(const Http2FrameHeader& header) {}

bool Http2DecoderAdapter::HasRequiredStreamIdZero(uint32_t stream_id) {}

bool Http2DecoderAdapter::HasRequiredStreamIdZero(
    const Http2FrameHeader& header) {}

void Http2DecoderAdapter::ReportReceiveCompressedFrame(
    const Http2FrameHeader& header) {}

void Http2DecoderAdapter::CommonStartHpackBlock() {}

// SpdyFramer calls HandleControlFrameHeadersData even if there are zero
// fragment bytes in the first frame, so do the same.
void Http2DecoderAdapter::MaybeAnnounceEmptyFirstHpackFragment() {}

void Http2DecoderAdapter::CommonHpackFragmentEnd() {}

}  // namespace http2

namespace spdy {

bool SpdyFramerVisitorInterface::OnGoAwayFrameData(const char* /*goaway_data*/,
                                                   size_t /*len*/) {}

}  // namespace spdy