blob: 2a27ddc15abe17bd178f20d3eb580b286e85b290 [file] [log] [blame]
wubf975eac2019-08-19 19:41:01 -07001// Copyright (c) 2019 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_QBONE_QBONE_CLIENT_H_
6#define QUICHE_QUIC_QBONE_QBONE_CLIENT_H_
7
8#include "net/third_party/quiche/src/quic/qbone/qbone_client_interface.h"
9#include "net/third_party/quiche/src/quic/qbone/qbone_client_session.h"
10#include "net/third_party/quiche/src/quic/qbone/qbone_packet_writer.h"
11#include "net/third_party/quiche/src/quic/tools/quic_client_base.h"
12#include "net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h"
dmcardled70b99e2019-12-12 09:52:39 -080013#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
wubf975eac2019-08-19 19:41:01 -070014
15namespace quic {
16// A QboneClient encapsulates connecting to a server via an epoll server
17// and setting up a Qbone tunnel. See the QboneTestClient in qbone_client_test
18// for usage.
19class QboneClient : public QuicClientBase, public QboneClientInterface {
20 public:
21 // Note that the epoll server, qbone writer, and handler are owned
22 // by the caller.
23 QboneClient(QuicSocketAddress server_address,
24 const QuicServerId& server_id,
25 const ParsedQuicVersionVector& supported_versions,
26 QuicSession::Visitor* session_owner,
27 const QuicConfig& config,
28 QuicEpollServer* epoll_server,
29 std::unique_ptr<ProofVerifier> proof_verifier,
30 QbonePacketWriter* qbone_writer,
31 QboneClientControlStream::Handler* qbone_handler);
32 ~QboneClient() override;
33 QboneClientSession* qbone_session();
34
35 // From QboneClientInterface. Accepts a given packet from the network and
36 // sends the packet down to the QBONE connection.
dmcardled70b99e2019-12-12 09:52:39 -080037 void ProcessPacketFromNetwork(quiche::QuicheStringPiece packet) override;
wubf975eac2019-08-19 19:41:01 -070038
39 protected:
40 int GetNumSentClientHellosFromSession() override;
41 int GetNumReceivedServerConfigUpdatesFromSession() override;
42
43 // This client does not resend saved data. This will be a no-op.
44 void ResendSavedData() override;
45
46 // This client does not resend saved data. This will be a no-op.
47 void ClearDataToResend() override;
48
49 // Takes ownership of |connection|.
50 std::unique_ptr<QuicSession> CreateQuicClientSession(
51 const ParsedQuicVersionVector& supported_versions,
52 QuicConnection* connection) override;
53
54 QbonePacketWriter* qbone_writer() { return qbone_writer_; }
55
56 QboneClientControlStream::Handler* qbone_control_handler() {
57 return qbone_handler_;
58 }
59
60 QuicSession::Visitor* session_owner() {
61 return session_owner_;
62 }
63
64 bool HasActiveRequests() override;
65
66 private:
67 QbonePacketWriter* qbone_writer_;
68 QboneClientControlStream::Handler* qbone_handler_;
69
70 QuicSession::Visitor* session_owner_;
71};
72
73} // namespace quic
74
75#endif // QUICHE_QUIC_QBONE_QBONE_CLIENT_H_