QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // Copyright (c) 2016 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_CHLO_EXTRACTOR_H_ |
| 6 | #define QUICHE_QUIC_CORE_CHLO_EXTRACTOR_H_ |
| 7 | |
| 8 | #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" |
| 9 | #include "net/third_party/quiche/src/quic/core/quic_packets.h" |
| 10 | |
| 11 | namespace quic { |
| 12 | |
| 13 | // A utility for extracting QUIC Client Hello messages from packets, |
| 14 | // without needs to spin up a full QuicSession. |
| 15 | class ChloExtractor { |
| 16 | public: |
| 17 | class Delegate { |
| 18 | public: |
| 19 | virtual ~Delegate() {} |
| 20 | |
| 21 | // Called when a CHLO message is found in the packets. |
| 22 | virtual void OnChlo(QuicTransportVersion version, |
| 23 | QuicConnectionId connection_id, |
| 24 | const CryptoHandshakeMessage& chlo) = 0; |
| 25 | }; |
| 26 | |
| 27 | // Extracts a CHLO message from |packet| and invokes the OnChlo |
| 28 | // method of |delegate|. Return true if a CHLO message was found, |
| 29 | // and false otherwise. If non-empty, |
| 30 | // |create_session_tag_indicators| contains a list of QUIC tags that |
| 31 | // if found will result in the session being created early, to |
| 32 | // enable support for multi-packet CHLOs. |
| 33 | static bool Extract(const QuicEncryptedPacket& packet, |
| 34 | const ParsedQuicVersionVector& versions, |
| 35 | const QuicTagVector& create_session_tag_indicators, |
| 36 | Delegate* delegate, |
| 37 | uint8_t connection_id_length); |
| 38 | |
| 39 | ChloExtractor(const ChloExtractor&) = delete; |
| 40 | ChloExtractor operator=(const ChloExtractor&) = delete; |
| 41 | }; |
| 42 | |
| 43 | } // namespace quic |
| 44 | |
| 45 | #endif // QUICHE_QUIC_CORE_CHLO_EXTRACTOR_H_ |