xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/qbone/bonnet/qbone_tunnel_interface.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2020 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_BONNET_QBONE_TUNNEL_INTERFACE_H_
6 #define QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_INTERFACE_H_
7 
8 #include "quiche/quic/qbone/qbone_client.h"
9 
10 namespace quic {
11 
12 // Interface for establishing bidirectional communication between a network
13 // device and a QboneClient.
14 class QboneTunnelInterface : public quic::QboneClientControlStream::Handler {
15  public:
16   QboneTunnelInterface() = default;
17 
18   QboneTunnelInterface(const QboneTunnelInterface&) = delete;
19   QboneTunnelInterface& operator=(const QboneTunnelInterface&) = delete;
20 
21   QboneTunnelInterface(QboneTunnelInterface&&) = delete;
22   QboneTunnelInterface& operator=(QboneTunnelInterface&&) = delete;
23 
24   enum State {
25     UNINITIALIZED,
26     IP_RANGE_REQUESTED,
27     START_REQUESTED,
28     STARTED,
29     LAME_DUCK_REQUESTED,
30     END_REQUESTED,
31     ENDED,
32     FAILED,
33   };
34 
35   // Wait and handle any events which occur.
36   // Returns true if there are any outstanding requests.
37   virtual bool WaitForEvents() = 0;
38 
39   // Wakes the tunnel if it is currently in WaitForEvents.
40   virtual void Wake() = 0;
41 
42   // Disconnect the tunnel, resetting it to an uninitialized state. This will
43   // force ConnectIfNeeded to reconnect on the next epoll cycle.
44   virtual void ResetTunnel() = 0;
45 
46   // Disconnect from the QBONE server.
47   virtual State Disconnect() = 0;
48 
49   // Callback handling responses from the QBONE server.
50   void OnControlRequest(const QboneClientRequest& request) override = 0;
51 
52   // Callback handling bad responses from the QBONE server. Currently, this is
53   // only called when the response is unparsable.
54   void OnControlError() override = 0;
55 
56   // Returns a string value of the given state.
57   virtual std::string StateToString(State state) = 0;
58 
59   virtual QboneClient* client() = 0;
60 
61   virtual State state() = 0;
62 
63   virtual std::string HealthString() = 0;
64 
65   virtual std::string ServerRegionString() = 0;
66 };
67 
68 }  // namespace quic
69 
70 #endif  // QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_INTERFACE_H_
71