blob: a0fe4fc70ddbcb09733265715308360d4a25817f [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"
13
14namespace quic {
15// A QboneClient encapsulates connecting to a server via an epoll server
16// and setting up a Qbone tunnel. See the QboneTestClient in qbone_client_test
17// for usage.
18class QboneClient : public QuicClientBase, public QboneClientInterface {
19 public:
20 // Note that the epoll server, qbone writer, and handler are owned
21 // by the caller.
22 QboneClient(QuicSocketAddress server_address,
23 const QuicServerId& server_id,
24 const ParsedQuicVersionVector& supported_versions,
25 QuicSession::Visitor* session_owner,
26 const QuicConfig& config,
27 QuicEpollServer* epoll_server,
28 std::unique_ptr<ProofVerifier> proof_verifier,
29 QbonePacketWriter* qbone_writer,
30 QboneClientControlStream::Handler* qbone_handler);
31 ~QboneClient() override;
32 QboneClientSession* qbone_session();
33
34 // From QboneClientInterface. Accepts a given packet from the network and
35 // sends the packet down to the QBONE connection.
36 void ProcessPacketFromNetwork(QuicStringPiece packet) override;
37
38 protected:
39 int GetNumSentClientHellosFromSession() override;
40 int GetNumReceivedServerConfigUpdatesFromSession() override;
41
42 // This client does not resend saved data. This will be a no-op.
43 void ResendSavedData() override;
44
45 // This client does not resend saved data. This will be a no-op.
46 void ClearDataToResend() override;
47
48 // Takes ownership of |connection|.
49 std::unique_ptr<QuicSession> CreateQuicClientSession(
50 const ParsedQuicVersionVector& supported_versions,
51 QuicConnection* connection) override;
52
53 QbonePacketWriter* qbone_writer() { return qbone_writer_; }
54
55 QboneClientControlStream::Handler* qbone_control_handler() {
56 return qbone_handler_;
57 }
58
59 QuicSession::Visitor* session_owner() {
60 return session_owner_;
61 }
62
63 bool HasActiveRequests() override;
64
65 private:
66 QbonePacketWriter* qbone_writer_;
67 QboneClientControlStream::Handler* qbone_handler_;
68
69 QuicSession::Visitor* session_owner_;
70};
71
72} // namespace quic
73
74#endif // QUICHE_QUIC_QBONE_QBONE_CLIENT_H_