1 // Copyright (c) 2012 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_TEST_TOOLS_SIMPLE_QUIC_FRAMER_H_ 6 #define QUICHE_QUIC_TEST_TOOLS_SIMPLE_QUIC_FRAMER_H_ 7 8 #include <memory> 9 #include <vector> 10 11 #include "quiche/quic/core/quic_framer.h" 12 #include "quiche/quic/core/quic_packets.h" 13 14 namespace quic { 15 16 struct QuicAckFrame; 17 18 namespace test { 19 20 class SimpleFramerVisitor; 21 22 // Peer to make public a number of otherwise private QuicFramer methods. 23 class SimpleQuicFramer { 24 public: 25 SimpleQuicFramer(); 26 explicit SimpleQuicFramer(const ParsedQuicVersionVector& supported_versions); 27 SimpleQuicFramer(const ParsedQuicVersionVector& supported_versions, 28 Perspective perspective); 29 SimpleQuicFramer(const SimpleQuicFramer&) = delete; 30 SimpleQuicFramer& operator=(const SimpleQuicFramer&) = delete; 31 ~SimpleQuicFramer(); 32 33 bool ProcessPacket(const QuicEncryptedPacket& packet); 34 void Reset(); 35 36 const QuicPacketHeader& header() const; 37 size_t num_frames() const; 38 const std::vector<QuicAckFrame>& ack_frames() const; 39 const std::vector<QuicConnectionCloseFrame>& connection_close_frames() const; 40 const std::vector<QuicStopWaitingFrame>& stop_waiting_frames() const; 41 const std::vector<QuicPathChallengeFrame>& path_challenge_frames() const; 42 const std::vector<QuicPathResponseFrame>& path_response_frames() const; 43 const std::vector<QuicPingFrame>& ping_frames() const; 44 const std::vector<QuicMessageFrame>& message_frames() const; 45 const std::vector<QuicWindowUpdateFrame>& window_update_frames() const; 46 const std::vector<QuicGoAwayFrame>& goaway_frames() const; 47 const std::vector<QuicRstStreamFrame>& rst_stream_frames() const; 48 const std::vector<std::unique_ptr<QuicStreamFrame>>& stream_frames() const; 49 const std::vector<std::unique_ptr<QuicCryptoFrame>>& crypto_frames() const; 50 const std::vector<QuicPaddingFrame>& padding_frames() const; 51 const QuicVersionNegotiationPacket* version_negotiation_packet() const; 52 EncryptionLevel last_decrypted_level() const; 53 const QuicEncryptedPacket* coalesced_packet() const; 54 55 QuicFramer* framer(); 56 SetSupportedVersions(const ParsedQuicVersionVector & versions)57 void SetSupportedVersions(const ParsedQuicVersionVector& versions) { 58 framer_.SetSupportedVersions(versions); 59 } 60 61 private: 62 QuicFramer framer_; 63 std::unique_ptr<SimpleFramerVisitor> visitor_; 64 }; 65 66 } // namespace test 67 68 } // namespace quic 69 70 #endif // QUICHE_QUIC_TEST_TOOLS_SIMPLE_QUIC_FRAMER_H_ 71