QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // 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 team | d9b8aba | 2019-12-11 10:13:38 -0800 | [diff] [blame] | 14 | #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 15 | |
| 16 | namespace quic { |
| 17 | |
| 18 | struct 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 team | d9b8aba | 2019-12-11 10:13:38 -0800 | [diff] [blame] | 25 | quiche::QuicheStringPiece data); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 26 | ~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 | }; |
| 46 | static_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_ |