vsock, move some defines

master
Jay Sorg 7 years ago committed by jsorg71
parent 50bd624cc4
commit 26507644e3

@ -586,17 +586,15 @@ g_sck_local_socket(void)
}
/*****************************************************************************/
#if defined(XRDP_ENABLE_VSOCK)
int
g_sck_vsock_socket(void)
{
#if defined(_WIN32)
return 0;
#else
#if defined(XRDP_ENABLE_VSOCK)
return socket(PF_VSOCK, SOCK_STREAM, 0);
#else
return 0;
#endif
}
#endif
/*****************************************************************************/
/* returns error */
@ -1007,13 +1005,10 @@ g_sck_local_bind(int sck, const char *port)
}
/*****************************************************************************/
#if defined(XRDP_ENABLE_VSOCK)
int
g_sck_vsock_bind(int sck, const char *port)
{
#if defined(_WIN32)
return -1;
#else
#if defined(XRDP_ENABLE_VSOCK)
struct sockaddr_vm s;
memset(&s, 0, sizeof(struct sockaddr_vm));
@ -1022,9 +1017,10 @@ g_sck_vsock_bind(int sck, const char *port)
s.svm_cid = VMADDR_CID_ANY;
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_vm));
#else
return -1;
#endif
}
#endif
#if defined(XRDP_ENABLE_IPV6)
/*****************************************************************************/

@ -37,11 +37,6 @@
#define g_tcp_select g_sck_select
#define g_close_wait_obj g_delete_wait_obj
#if defined(XRDP_ENABLE_VSOCK)
#define g_vsock_socket g_sck_vsock_socket
#define g_vsock_bind g_sck_vsock_bind
#endif
int g_rm_temp_dir(void);
int g_mk_socket_path(const char* app_name);
void g_init(const char* app_name);
@ -67,9 +62,7 @@ int g_sck_get_send_buffer_bytes(int sck, int *bytes);
int g_sck_set_recv_buffer_bytes(int sck, int bytes);
int g_sck_get_recv_buffer_bytes(int sck, int *bytes);
int g_sck_local_socket(void);
#if defined(XRDP_ENABLE_VSOCK)
int g_sck_vsock_socket(void);
#endif
int g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid);
void g_sck_close(int sck);
int g_tcp_connect(int sck, const char* address, const char* port);
@ -77,9 +70,7 @@ int g_sck_local_connect(int sck, const char* port);
int g_sck_set_non_blocking(int sck);
int g_tcp_bind(int sck, const char *port);
int g_sck_local_bind(int sck, const char* port);
#if defined(XRDP_ENABLE_VSOCK)
int g_sck_vsock_bind(int sck, const char* port);
#endif
int g_tcp_bind_address(int sck, const char* port, const char* address);
int g_sck_listen(int sck);
int g_tcp_accept(int sck);

@ -831,16 +831,15 @@ trans_listen_address(struct trans *self, char *port, const char *address)
}
}
}
#if defined(XRDP_ENABLE_VSOCK)
else if (self->mode == TRANS_MODE_VSOCK) /* vsock socket */
{
self->sck = g_vsock_socket();
self->sck = g_sck_vsock_socket();
if (self->sck < 0)
return 1;
g_tcp_set_non_blocking(self->sck);
if (g_vsock_bind(self->sck, port) == 0)
if (g_sck_vsock_bind(self->sck, port) == 0)
{
if (g_tcp_listen(self->sck) == 0)
{
@ -850,7 +849,6 @@ trans_listen_address(struct trans *self, char *port, const char *address)
}
}
}
#endif
return 1;
}

@ -26,10 +26,7 @@
#define TRANS_MODE_TCP 1
#define TRANS_MODE_UNIX 2
#if defined(XRDP_ENABLE_VSOCK)
#define TRANS_MODE_VSOCK 3
#endif
#define TRANS_TYPE_LISTENER 1
#define TRANS_TYPE_SERVER 2

@ -206,7 +206,6 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
}
}
}
#if defined(XRDP_ENABLE_VSOCK)
if (g_strcasecmp(val, "use_vsock") == 0)
{
val = (char *)list_get_item(values, index);
@ -215,7 +214,6 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
*mode = TRANS_MODE_VSOCK;
}
}
#endif
if (g_strcasecmp(val, "address") == 0)
{
val = (char *)list_get_item(values, index);
@ -381,13 +379,11 @@ xrdp_listen_main_loop(struct xrdp_listen *self)
/* not valid with UDS */
tcp_nodelay = 0;
}
#if defined(XRDP_ENABLE_VSOCK)
else if (self->listen_trans->mode == TRANS_MODE_VSOCK)
{
/* not valid with VSOCK */
tcp_nodelay = 0;
}
#endif
/* Create socket */
error = trans_listen_address(self->listen_trans, port, address);
@ -568,6 +564,13 @@ xrdp_listen_main_loop(struct xrdp_listen *self)
{
log_message(LOG_LEVEL_ERROR,"xrdp_listen_main_loop: listen error, possible port "
"already in use");
#if !defined(XRDP_ENABLE_VSOCK)
if (self->listen_trans->mode == TRANS_MODE_VSOCK)
{
log_message(LOG_LEVEL_ERROR,"xrdp_listen_main_loop: listen error, "
"vsock support not compiled and config requested");
}
#endif
}
self->status = -1;

Loading…
Cancel
Save