Android-cuttlefish cvd tool
Namespaces | Functions | Variables
socket_vsock_proxy.cpp File Reference
#include <signal.h>
#include <chrono>
#include <memory>
#include <sstream>
#include <android-base/logging.h>
#include <gflags/gflags.h>
#include "cuttlefish/common/frontend/socket_vsock_proxy/client.h"
#include "cuttlefish/common/frontend/socket_vsock_proxy/server.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/utils/result.h"
#include "cuttlefish/common/libs/utils/socket2socket_proxy.h"
#include "cuttlefish/common/libs/utils/tee_logging.h"
#include "cuttlefish/host/commands/kernel_log_monitor/utils.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/logging.h"
Include dependency graph for socket_vsock_proxy.cpp:

Namespaces

namespace  cuttlefish
 
namespace  cuttlefish::socket_proxy
 
namespace  cuttlefish::socket_proxy::anonymous_namespace{socket_vsock_proxy.cpp}
 

Functions

constexpr std::chrono::milliseconds TCP_SERVER_RETRIES_DELAY (1250)
 
constexpr std::chrono::seconds TCP_CLIENT_TIMEOUT (1)
 
 DEFINE_string (label, "socket_vsock_proxy", "Label which is used only for logging. " "Log messages will look like [label] message")
 
 DEFINE_string (server_type, "", "The type of server to host, `vsock` or `tcp`.")
 
 DEFINE_string (client_type, "", "The type of server to host, `vsock` or `tcp`.")
 
 DEFINE_int32 (server_tcp_port, 0, "Server TCP port")
 
 DEFINE_string (client_tcp_host, "localhost", "Client TCP host (default localhost)")
 
 DEFINE_int32 (client_tcp_port, 0, "Client TCP port")
 
 DEFINE_int32 (server_vsock_port, 0, "vsock port")
 
 DEFINE_int32 (server_vsock_id, 0, "Vsock cid which server listens to")
 
 DEFINE_int32 (client_vsock_id, 0, "Vsock cid to initiate connections to")
 
 DEFINE_int32 (client_vsock_port, 0, "Vsock port to initiate connections to")
 
 DEFINE_int32 (server_fd, -1, "A file descriptor. If set the passed file descriptor will be used as " "the server and the corresponding port flag will be ignored")
 
 DEFINE_int32 (events_fd, -1, "A file descriptor. If set it will listen for the events " "to start / stop proxying. This option can be used only " "if start_event_id is provided (stop_event_id is optional)")
 
 DEFINE_int32 (start_event_id, -1, "Kernel event id (cuttlefish::monitor::Event from " "kernel_log_server.h) that we will listen to start proxy")
 
 DEFINE_int32 (stop_event_id, -1, "Kernel event id (cuttlefish::monitor::Event from " "kernel_log_server.h) that we will listen to stop proxy")
 
 DEFINE_bool (restore, false, "Wait on the restore_adbd_pipe instead of the initial start event")
 
 DEFINE_bool (vhost_user_vsock, false, "A flag to user vhost_user_vsock")
 
static bool cuttlefish::socket_proxy::anonymous_namespace{socket_vsock_proxy.cpp}::use_vhost_vsock ()
 
static std::unique_ptr< Server > cuttlefish::socket_proxy::anonymous_namespace{socket_vsock_proxy.cpp}::BuildServer ()
 
static std::unique_ptr< Client > cuttlefish::socket_proxy::anonymous_namespace{socket_vsock_proxy.cpp}::BuildClient ()
 
static Result< std::unique_ptr< ProxyServer > > cuttlefish::socket_proxy::anonymous_namespace{socket_vsock_proxy.cpp}::StartProxyAsync (Server &server, Client &client)
 
static Result< void > cuttlefish::socket_proxy::anonymous_namespace{socket_vsock_proxy.cpp}::ListenEventsAndProxy (int events_fd, const monitor::Event start, const monitor::Event stop, Server &server, Client &client)
 
Result< void > cuttlefish::socket_proxy::anonymous_namespace{socket_vsock_proxy.cpp}::Main ()
 
int main (int argc, char *argv[])
 

Variables

constexpr int TCP_SERVER_START_RETRIES_COUNT = 10
 
constexpr char TRANSPORT_TCP [] = "tcp"
 
constexpr char TRANSPORT_VSOCK [] = "vsock"
 

Function Documentation

◆ DEFINE_bool() [1/2]

DEFINE_bool ( restore  ,
false  ,
"Wait on the restore_adbd_pipe instead of the initial start event"   
)

◆ DEFINE_bool() [2/2]

DEFINE_bool ( vhost_user_vsock  ,
false  ,
"A flag to user vhost_user_vsock"   
)

◆ DEFINE_int32() [1/10]

DEFINE_int32 ( client_tcp_port  ,
,
"Client TCP port"   
)

◆ DEFINE_int32() [2/10]

DEFINE_int32 ( client_vsock_id  ,
,
"Vsock cid to initiate connections to"   
)

◆ DEFINE_int32() [3/10]

DEFINE_int32 ( client_vsock_port  ,
,
"Vsock port to initiate connections to"   
)

◆ DEFINE_int32() [4/10]

DEFINE_int32 ( events_fd  ,
1,
"A file descriptor. If set it will listen for the events " "to start / stop proxying. This option can be used only " "if start_event_id is provided (stop_event_id is optional)"   
)

◆ DEFINE_int32() [5/10]

DEFINE_int32 ( server_fd  ,
1,
"A file descriptor. If set the passed file descriptor will be used as " "the server and the corresponding port flag will be ignored"   
)

◆ DEFINE_int32() [6/10]

DEFINE_int32 ( server_tcp_port  ,
,
"Server TCP port"   
)

◆ DEFINE_int32() [7/10]

DEFINE_int32 ( server_vsock_id  ,
,
"Vsock cid which server listens to"   
)

◆ DEFINE_int32() [8/10]

DEFINE_int32 ( server_vsock_port  ,
,
"vsock port"   
)

◆ DEFINE_int32() [9/10]

DEFINE_int32 ( start_event_id  ,
1,
"Kernel event id (cuttlefish::monitor::Event from " "kernel_log_server.h) that we will listen to start proxy"   
)

◆ DEFINE_int32() [10/10]

DEFINE_int32 ( stop_event_id  ,
1,
"Kernel event id (cuttlefish::monitor::Event from " "kernel_log_server.h) that we will listen to stop proxy"   
)

◆ DEFINE_string() [1/4]

DEFINE_string ( client_tcp_host  ,
"localhost"  ,
"Client TCP host (default localhost)"   
)

◆ DEFINE_string() [2/4]

DEFINE_string ( client_type  ,
""  ,
"The type of server to  host,
`vsock` or `tcp`."   
)

◆ DEFINE_string() [3/4]

DEFINE_string ( label  ,
"socket_vsock_proxy"  ,
"Label which is used only for logging. " "Log messages will look like message"  [label] 
)

◆ DEFINE_string() [4/4]

DEFINE_string ( server_type  ,
""  ,
"The type of server to  host,
`vsock` or `tcp`."   
)

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ TCP_CLIENT_TIMEOUT()

constexpr std::chrono::seconds TCP_CLIENT_TIMEOUT ( )
constexpr

◆ TCP_SERVER_RETRIES_DELAY()

constexpr std::chrono::milliseconds TCP_SERVER_RETRIES_DELAY ( 1250  )
constexpr

Variable Documentation

◆ TCP_SERVER_START_RETRIES_COUNT

constexpr int TCP_SERVER_START_RETRIES_COUNT = 10
constexpr

◆ TRANSPORT_TCP

constexpr char TRANSPORT_TCP[] = "tcp"
constexpr

◆ TRANSPORT_VSOCK

constexpr char TRANSPORT_VSOCK[] = "vsock"
constexpr