blob: 28434cb636286e552b783b4eecb3886b391bc8ae [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright (c) 2018 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_CRYPTO_FRAME_H_
6#define QUICHE_QUIC_CORE_FRAMES_QUIC_CRYPTO_FRAME_H_
7
8#include <memory>
9#include <ostream>
10
11#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h"
12#include "net/third_party/quiche/src/quic/core/quic_types.h"
13#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
QUICHE teamd9b8aba2019-12-11 10:13:38 -080014#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050015
16namespace quic {
17
18struct QUIC_EXPORT_PRIVATE QuicCryptoFrame {
19 QuicCryptoFrame();
20 QuicCryptoFrame(EncryptionLevel level,
21 QuicStreamOffset offset,
22 QuicPacketLength data_length);
23 QuicCryptoFrame(EncryptionLevel level,
24 QuicStreamOffset offset,
QUICHE teamd9b8aba2019-12-11 10:13:38 -080025 quiche::QuicheStringPiece data);
QUICHE teama6ef0a62019-03-07 20:34:33 -050026 ~QuicCryptoFrame();
27
28 friend QUIC_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
29 const QuicCryptoFrame& s);
30
31 // When writing a crypto frame to a packet, the packet must be encrypted at
32 // |level|. When a crypto frame is read, the encryption level of the packet it
33 // was received in is put in |level|.
34 EncryptionLevel level;
35 QuicPacketLength data_length;
36 // When reading, |data_buffer| points to the data that was received in the
37 // frame. |data_buffer| is not used when writing.
38 const char* data_buffer;
39 QuicStreamOffset offset; // Location of this data in the stream.
40
41 QuicCryptoFrame(EncryptionLevel level,
42 QuicStreamOffset offset,
43 const char* data_buffer,
44 QuicPacketLength data_length);
45};
46static_assert(sizeof(QuicCryptoFrame) <= 64,
47 "Keep the QuicCryptoFrame size to a cacheline.");
48
49} // namespace quic
50
51#endif // QUICHE_QUIC_CORE_FRAMES_QUIC_CRYPTO_FRAME_H_