Merge branch 'devel' of github.com:NeutrinoLabs/xrdp into devel
This commit is contained in:
+86
-20
@@ -24,12 +24,13 @@
|
||||
#include "parse.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct trans *APP_CC
|
||||
struct trans *
|
||||
APP_CC
|
||||
trans_create(int mode, int in_size, int out_size)
|
||||
{
|
||||
struct trans *self = (struct trans *)NULL;
|
||||
struct trans *self = (struct trans *) NULL;
|
||||
|
||||
self = (struct trans *)g_malloc(sizeof(struct trans), 1);
|
||||
self = (struct trans *) g_malloc(sizeof(struct trans), 1);
|
||||
|
||||
if (self != NULL)
|
||||
{
|
||||
@@ -38,6 +39,10 @@ trans_create(int mode, int in_size, int out_size)
|
||||
make_stream(self->out_s);
|
||||
init_stream(self->out_s, out_size);
|
||||
self->mode = mode;
|
||||
self->tls = 0;
|
||||
/* assign tcp functions */
|
||||
self->trans_read_call = trans_tcp_force_read_s;
|
||||
self->trans_write_call = trans_tcp_force_write_s;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -68,6 +73,11 @@ trans_delete(struct trans *self)
|
||||
g_free(self->listen_filename);
|
||||
}
|
||||
|
||||
if (self->tls != 0)
|
||||
{
|
||||
xrdp_tls_delete(self->tls);
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
@@ -92,8 +102,7 @@ trans_get_wait_objs(struct trans *self, tbus *objs, int *count)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_get_wait_objs_rw(struct trans *self,
|
||||
tbus *robjs, int *rcount,
|
||||
trans_get_wait_objs_rw(struct trans *self, tbus *robjs, int *rcount,
|
||||
tbus *wobjs, int *wcount)
|
||||
{
|
||||
if (self == 0)
|
||||
@@ -174,8 +183,8 @@ send_waiting(struct trans *self, int block)
|
||||
int APP_CC
|
||||
trans_check_wait_objs(struct trans *self)
|
||||
{
|
||||
tbus in_sck = (tbus)0;
|
||||
struct trans *in_trans = (struct trans *)NULL;
|
||||
tbus in_sck = (tbus) 0;
|
||||
struct trans *in_trans = (struct trans *) NULL;
|
||||
int read_bytes = 0;
|
||||
int to_read = 0;
|
||||
int read_so_far = 0;
|
||||
@@ -224,8 +233,10 @@ trans_check_wait_objs(struct trans *self)
|
||||
in_trans->type1 = TRANS_TYPE_SERVER;
|
||||
in_trans->status = TRANS_STATUS_UP;
|
||||
in_trans->is_term = self->is_term;
|
||||
g_strncpy(in_trans->addr, self->addr, sizeof(self->addr) - 1);
|
||||
g_strncpy(in_trans->port, self->port, sizeof(self->port) - 1);
|
||||
g_strncpy(in_trans->addr, self->addr,
|
||||
sizeof(self->addr) - 1);
|
||||
g_strncpy(in_trans->port, self->port,
|
||||
sizeof(self->port) - 1);
|
||||
|
||||
if (self->trans_conn_in(self, in_trans) != 0)
|
||||
{
|
||||
@@ -243,7 +254,7 @@ trans_check_wait_objs(struct trans *self)
|
||||
{
|
||||
if (g_tcp_can_recv(self->sck, 0))
|
||||
{
|
||||
read_so_far = (int)(self->in_s->end - self->in_s->data);
|
||||
read_so_far = (int) (self->in_s->end - self->in_s->data);
|
||||
to_read = self->header_size - read_so_far;
|
||||
|
||||
if (to_read > 0)
|
||||
@@ -275,7 +286,7 @@ trans_check_wait_objs(struct trans *self)
|
||||
}
|
||||
}
|
||||
|
||||
read_so_far = (int)(self->in_s->end - self->in_s->data);
|
||||
read_so_far = (int) (self->in_s->end - self->in_s->data);
|
||||
|
||||
if (read_so_far == self->header_size)
|
||||
{
|
||||
@@ -299,10 +310,15 @@ trans_check_wait_objs(struct trans *self)
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
||||
{
|
||||
return self->trans_read_call(self, in_s, size);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_tcp_force_read_s(struct trans *self, struct stream *in_s, int size)
|
||||
{
|
||||
int rcvd;
|
||||
|
||||
@@ -318,7 +334,9 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rcvd = g_tcp_recv(self->sck, in_s->end, size, 0);
|
||||
|
||||
if (rcvd == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -370,6 +388,12 @@ trans_force_read(struct trans *self, int size)
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_force_write_s(struct trans *self, struct stream *out_s)
|
||||
{
|
||||
return self->trans_write_call(self, out_s);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_tcp_force_write_s(struct trans *self, struct stream *out_s)
|
||||
{
|
||||
int size;
|
||||
int total;
|
||||
@@ -380,7 +404,7 @@ trans_force_write_s(struct trans *self, struct stream *out_s)
|
||||
return 1;
|
||||
}
|
||||
|
||||
size = (int)(out_s->end - out_s->data);
|
||||
size = (int) (out_s->end - out_s->data);
|
||||
total = 0;
|
||||
|
||||
if (send_waiting(self, 1) != 0)
|
||||
@@ -455,7 +479,7 @@ trans_write_copy(struct trans *self)
|
||||
}
|
||||
|
||||
out_s = self->out_s;
|
||||
size = (int)(out_s->end - out_s->data);
|
||||
size = (int) (out_s->end - out_s->data);
|
||||
make_stream(wait_s);
|
||||
init_stream(wait_s, size);
|
||||
out_uint8a(wait_s, out_s->data, size);
|
||||
@@ -610,14 +634,15 @@ trans_listen(struct trans *self, char *port)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
struct stream *APP_CC
|
||||
struct stream *
|
||||
APP_CC
|
||||
trans_get_in_s(struct trans *self)
|
||||
{
|
||||
struct stream *rv = (struct stream *)NULL;
|
||||
struct stream *rv = (struct stream *) NULL;
|
||||
|
||||
if (self == NULL)
|
||||
{
|
||||
rv = (struct stream *)NULL;
|
||||
rv = (struct stream *) NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -628,14 +653,15 @@ trans_get_in_s(struct trans *self)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
struct stream *APP_CC
|
||||
struct stream *
|
||||
APP_CC
|
||||
trans_get_out_s(struct trans *self, int size)
|
||||
{
|
||||
struct stream *rv = (struct stream *)NULL;
|
||||
struct stream *rv = (struct stream *) NULL;
|
||||
|
||||
if (self == NULL)
|
||||
{
|
||||
rv = (struct stream *)NULL;
|
||||
rv = (struct stream *) NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -645,3 +671,43 @@ trans_get_out_s(struct trans *self, int size)
|
||||
|
||||
return rv;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
trans_set_tls_mode(struct trans *self, const char *key, const char *cert)
|
||||
{
|
||||
self->tls = xrdp_tls_create(self, key, cert);
|
||||
if (self->tls == NULL)
|
||||
{
|
||||
g_writeln("trans_set_tls_mode: xrdp_tls_create malloc error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_tls_accept(self->tls) != 0)
|
||||
{
|
||||
g_writeln("trans_set_tls_mode: xrdp_tls_accept failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* assign tls functions */
|
||||
self->trans_read_call = xrdp_tls_force_read_s;
|
||||
self->trans_write_call = xrdp_tls_force_write_s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
trans_shutdown_tls_mode(struct trans *self)
|
||||
{
|
||||
if (self->tls != NULL)
|
||||
{
|
||||
return xrdp_tls_disconnect(self->tls);
|
||||
}
|
||||
|
||||
/* set callback back to tcp
|
||||
self->trans_read_call = trans_tcp_force_read_s;
|
||||
self->trans_write_call = trans_tcp_force_write_s;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user