• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2022 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #pragma once
17 
18 #include "common/libs/fs/shared_fd.h"
19 
20 namespace cuttlefish {
21 namespace socket_proxy {
22 
23 class Client {
24  public:
25   virtual SharedFD Start() = 0;
26   virtual std::string Describe() const = 0;
27   virtual ~Client() = default;
28 };
29 
30 class TcpClient : public Client {
31  public:
32   TcpClient(std::string host, int port);
33   SharedFD Start() override;
34   std::string Describe() const override;
35 
36  private:
37   std::string host_;
38   int port_;
39   int last_failure_reason_ = 0;
40 };
41 
42 class VsockClient : public Client {
43  public:
44   VsockClient(int id, int port);
45   SharedFD Start() override;
46   std::string Describe() const override;
47 
48  private:
49   int id_;
50   int port_;
51   int last_failure_reason_ = 0;
52 };
53 
54 }
55 }