summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2010-05-04 09:24:24 +0000
committerjsorg71 <jsorg71>2010-05-04 09:24:24 +0000
commit574355f3e3a24ad7f0c27bc4c7fd2248ed89e99e (patch)
treed70599f6a8d101c6d92f1fa4aa23d929ac392342
parent27e097663f6b70801268e53d24a8fa45517367e9 (diff)
downloadxrdp-proprietary-574355f3e3a24ad7f0c27bc4c7fd2248ed89e99e.tar.gz
xrdp-proprietary-574355f3e3a24ad7f0c27bc4c7fd2248ed89e99e.zip
use trans
-rw-r--r--libxrdp/libxrdp.c6
-rw-r--r--libxrdp/libxrdp.h14
-rw-r--r--libxrdp/libxrdpinc.h4
-rw-r--r--libxrdp/xrdp_iso.c6
-rw-r--r--libxrdp/xrdp_mcs.c6
-rw-r--r--libxrdp/xrdp_rdp.c6
-rw-r--r--libxrdp/xrdp_sec.c6
-rw-r--r--libxrdp/xrdp_tcp.c108
-rw-r--r--xrdp/xrdp.h2
-rw-r--r--xrdp/xrdp_listen.c100
-rw-r--r--xrdp/xrdp_mm.c8
-rw-r--r--xrdp/xrdp_process.c38
-rw-r--r--xrdp/xrdp_types.h6
13 files changed, 120 insertions, 190 deletions
diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c
index 23689db5..7e7446dd 100644
--- a/libxrdp/libxrdp.c
+++ b/libxrdp/libxrdp.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
this is the interface to libxrdp
@@ -24,13 +24,13 @@
/******************************************************************************/
struct xrdp_session* EXPORT_CC
-libxrdp_init(long id, int sck)
+libxrdp_init(tbus id, struct trans* trans)
{
struct xrdp_session* session;
session = (struct xrdp_session*)g_malloc(sizeof(struct xrdp_session), 1);
session->id = id;
- session->rdp = xrdp_rdp_create(session, sck);
+ session->rdp = xrdp_rdp_create(session, trans);
session->orders = xrdp_orders_create(session, (struct xrdp_rdp*)session->rdp);
session->client_info = &(((struct xrdp_rdp*)session->rdp)->client_info);
make_stream(session->s);
diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h
index 65b69b89..cff56a7c 100644
--- a/libxrdp/libxrdp.h
+++ b/libxrdp/libxrdp.h
@@ -28,6 +28,7 @@
#endif
#include "arch.h"
#include "parse.h"
+#include "trans.h"
#include "xrdp_constants.h"
#include "defines.h"
#include "os_calls.h"
@@ -40,8 +41,7 @@
/* tcp */
struct xrdp_tcp
{
- int sck;
- int sck_closed;
+ struct trans* trans;
struct xrdp_iso* iso_layer; /* owner */
};
@@ -214,7 +214,7 @@ struct xrdp_orders
/* xrdp_tcp.c */
struct xrdp_tcp* APP_CC
-xrdp_tcp_create(struct xrdp_iso* owner, int sck);
+xrdp_tcp_create(struct xrdp_iso* owner, struct trans* trans);
void APP_CC
xrdp_tcp_delete(struct xrdp_tcp* self);
int APP_CC
@@ -226,7 +226,7 @@ xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s);
/* xrdp_iso.c */
struct xrdp_iso* APP_CC
-xrdp_iso_create(struct xrdp_mcs* owner, int sck);
+xrdp_iso_create(struct xrdp_mcs* owner, struct trans* trans);
void APP_CC
xrdp_iso_delete(struct xrdp_iso* self);
int APP_CC
@@ -240,7 +240,7 @@ xrdp_iso_incoming(struct xrdp_iso* self);
/* xrdp_mcs.c */
struct xrdp_mcs* APP_CC
-xrdp_mcs_create(struct xrdp_sec* owner, int sck,
+xrdp_mcs_create(struct xrdp_sec* owner, struct trans* trans,
struct stream* client_mcs_data,
struct stream* server_mcs_data);
void APP_CC
@@ -258,7 +258,7 @@ xrdp_mcs_disconnect(struct xrdp_mcs* self);
/* xrdp_sec.c */
struct xrdp_sec* APP_CC
-xrdp_sec_create(struct xrdp_rdp* owner, int sck, int crypt_level,
+xrdp_sec_create(struct xrdp_rdp* owner, struct trans* trans, int crypt_level,
int channel_code);
void APP_CC
xrdp_sec_delete(struct xrdp_sec* self);
@@ -279,7 +279,7 @@ xrdp_sec_disconnect(struct xrdp_sec* self);
/* xrdp_rdp.c */
struct xrdp_rdp* APP_CC
-xrdp_rdp_create(struct xrdp_session* session, int sck);
+xrdp_rdp_create(struct xrdp_session* session, struct trans* trans);
void APP_CC
xrdp_rdp_delete(struct xrdp_rdp* self);
int APP_CC
diff --git a/libxrdp/libxrdpinc.h b/libxrdp/libxrdpinc.h
index db54ce33..524acafa 100644
--- a/libxrdp/libxrdpinc.h
+++ b/libxrdp/libxrdpinc.h
@@ -101,7 +101,7 @@ struct xrdp_rect
struct xrdp_session
{
long id;
- int sck;
+ struct trans* trans;
int (*callback)(long id, int msg, long param1, long param2, long param3,
long param4);
void* rdp;
@@ -113,7 +113,7 @@ struct xrdp_session
};
struct xrdp_session* DEFAULT_CC
-libxrdp_init(long id, int sck);
+libxrdp_init(tbus id, struct trans* trans);
int DEFAULT_CC
libxrdp_exit(struct xrdp_session* session);
int DEFAULT_CC
diff --git a/libxrdp/xrdp_iso.c b/libxrdp/xrdp_iso.c
index 939f19ab..7fee92e6 100644
--- a/libxrdp/xrdp_iso.c
+++ b/libxrdp/xrdp_iso.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
iso layer
@@ -24,14 +24,14 @@
/*****************************************************************************/
struct xrdp_iso* APP_CC
-xrdp_iso_create(struct xrdp_mcs* owner, int sck)
+xrdp_iso_create(struct xrdp_mcs* owner, struct trans* trans)
{
struct xrdp_iso* self;
DEBUG((" in xrdp_iso_create"));
self = (struct xrdp_iso*)g_malloc(sizeof(struct xrdp_iso), 1);
self->mcs_layer = owner;
- self->tcp_layer = xrdp_tcp_create(self, sck);
+ self->tcp_layer = xrdp_tcp_create(self, trans);
DEBUG((" out xrdp_iso_create"));
return self;
}
diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c
index 8a3406be..af65faf2 100644
--- a/libxrdp/xrdp_mcs.c
+++ b/libxrdp/xrdp_mcs.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
mcs layer
@@ -24,7 +24,7 @@
/*****************************************************************************/
struct xrdp_mcs* APP_CC
-xrdp_mcs_create(struct xrdp_sec* owner, int sck,
+xrdp_mcs_create(struct xrdp_sec* owner, struct trans* trans,
struct stream* client_mcs_data,
struct stream* server_mcs_data)
{
@@ -37,7 +37,7 @@ xrdp_mcs_create(struct xrdp_sec* owner, int sck,
self->chanid = 1001;
self->client_mcs_data = client_mcs_data;
self->server_mcs_data = server_mcs_data;
- self->iso_layer = xrdp_iso_create(self, sck);
+ self->iso_layer = xrdp_iso_create(self, trans);
self->channel_list = list_create();
DEBUG((" out xrdp_mcs_create"));
return self;
diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c
index 1eea4f46..63019b0d 100644
--- a/libxrdp/xrdp_rdp.c
+++ b/libxrdp/xrdp_rdp.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
rdp layer
@@ -122,7 +122,7 @@ xrdp_rdp_read_config(struct xrdp_client_info* client_info)
/*****************************************************************************/
struct xrdp_rdp* APP_CC
-xrdp_rdp_create(struct xrdp_session* session, int sck)
+xrdp_rdp_create(struct xrdp_session* session, struct trans* trans)
{
struct xrdp_rdp* self;
@@ -133,7 +133,7 @@ xrdp_rdp_create(struct xrdp_session* session, int sck)
/* read ini settings */
xrdp_rdp_read_config(&self->client_info);
/* create sec layer */
- self->sec_layer = xrdp_sec_create(self, sck, self->client_info.crypt_level,
+ self->sec_layer = xrdp_sec_create(self, trans, self->client_info.crypt_level,
self->client_info.channel_code);
/* default 8 bit v1 color bitmap cache entries and size */
self->client_info.cache1_entries = 600;
diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c
index 758283ad..99067ba7 100644
--- a/libxrdp/xrdp_sec.c
+++ b/libxrdp/xrdp_sec.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
secure layer
@@ -124,7 +124,7 @@ hex_str_to_bin(char* in, char* out, int out_len)
/*****************************************************************************/
struct xrdp_sec* APP_CC
-xrdp_sec_create(struct xrdp_rdp* owner, int sck, int crypt_level,
+xrdp_sec_create(struct xrdp_rdp* owner, struct trans* trans, int crypt_level,
int channel_code)
{
struct xrdp_sec* self;
@@ -152,7 +152,7 @@ xrdp_sec_create(struct xrdp_rdp* owner, int sck, int crypt_level,
self->channel_code = channel_code;
self->decrypt_rc4_info = ssl_rc4_info_create();
self->encrypt_rc4_info = ssl_rc4_info_create();
- self->mcs_layer = xrdp_mcs_create(self, sck, &self->client_mcs_data,
+ self->mcs_layer = xrdp_mcs_create(self, trans, &self->client_mcs_data,
&self->server_mcs_data);
self->chan_layer = xrdp_channel_create(self, self->mcs_layer);
DEBUG((" out xrdp_sec_create"));
diff --git a/libxrdp/xrdp_tcp.c b/libxrdp/xrdp_tcp.c
index 67ba1f68..86a79ea7 100644
--- a/libxrdp/xrdp_tcp.c
+++ b/libxrdp/xrdp_tcp.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
tcp layer
@@ -24,14 +24,14 @@
/*****************************************************************************/
struct xrdp_tcp* APP_CC
-xrdp_tcp_create(struct xrdp_iso* owner, int sck)
+xrdp_tcp_create(struct xrdp_iso* owner, struct trans* trans)
{
struct xrdp_tcp* self;
DEBUG((" in xrdp_tcp_create"));
self = (struct xrdp_tcp*)g_malloc(sizeof(struct xrdp_tcp), 1);
self->iso_layer = owner;
- self->sck = sck;
+ self->trans = trans;
DEBUG((" out xrdp_tcp_create"));
return self;
}
@@ -58,54 +58,12 @@ xrdp_tcp_init(struct xrdp_tcp* self, struct stream* s)
int APP_CC
xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
{
- int rcvd;
- struct xrdp_session* session;
-
- if (self->sck_closed)
- {
- DEBUG((" in xrdp_tcp_recv, sck closed"));
- return 1;
- }
DEBUG((" in xrdp_tcp_recv, gota get %d bytes", len));
- session = self->iso_layer->mcs_layer->sec_layer->rdp_layer->session;
init_stream(s, len);
- while (len > 0)
+ if (trans_force_read_s(self->trans, s, len) != 0)
{
- rcvd = g_tcp_recv(self->sck, s->end, len, 0);
- if (rcvd == -1)
- {
- if (g_tcp_last_error_would_block(self->sck))
- {
- if (!g_tcp_can_recv(self->sck, 10))
- {
- if (session->is_term != 0)
- {
- if (session->is_term())
- {
- DEBUG((" out xrdp_tcp_recv, terminated"));
- return 1;
- }
- }
- }
- }
- else
- {
- self->sck_closed = 1;
- DEBUG((" error = -1 in xrdp_tcp_recv socket %d", self->sck));
- return 1;
- }
- }
- else if (rcvd == 0)
- {
- self->sck_closed = 1;
- DEBUG((" error = 0 in xrdp_tcp_recv socket %d", self->sck));
- return 1;
- }
- else
- {
- s->end += rcvd;
- len -= rcvd;
- }
+ DEBUG((" error in trans_force_read_s"));
+ return 1;
}
DEBUG((" out xrdp_tcp_recv"));
return 0;
@@ -116,59 +74,11 @@ xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
int APP_CC
xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
{
- int len;
- int total;
- int sent;
- struct xrdp_session* session;
-
- if (self->sck_closed)
- {
- DEBUG((" in xrdp_tcp_send, sck closed"));
- return 1;
- }
- len = s->end - s->data;
DEBUG((" in xrdp_tcp_send, gota send %d bytes", len));
- session = self->iso_layer->mcs_layer->sec_layer->rdp_layer->session;
- total = 0;
- while (total < len)
+ if (trans_force_write_s(self->trans, s) != 0)
{
- sent = g_tcp_send(self->sck, s->data + total, len - total, 0);
- if (sent == -1)
- {
- if (g_tcp_last_error_would_block(self->sck))
- {
- if (!g_tcp_can_send(self->sck, 10))
- {
- if (session->is_term != 0)
- {
- if (session->is_term())
- {
- DEBUG((" out xrdp_tcp_send, terminated"));
- return 1;
- }
- }
- }
- }
- else
- {
- self->sck_closed = 1;
- DEBUG((" error = -1 in xrdp_tcp_send socket %d", self->sck));
- return 1;
- }
- }
- else if (sent == 0)
- {
- self->sck_closed = 1;
- DEBUG((" error = 0 in xrdp_tcp_send socket %d", self->sck));
- return 1;
- }
- else
- {
-#if defined(XRDP_DEBUG)
- g_hexdump(s->data + total, sent);
-#endif
- total = total + sent;
- }
+ DEBUG((" error in trans_force_write_s"));
+ return 1;
}
DEBUG((" out xrdp_tcp_send, sent %d bytes ok", len));
return 0;
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index 4cec5931..1ff1afc3 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -26,6 +26,7 @@
#endif
#include "arch.h"
#include "parse.h"
+#include "trans.h"
#include "libxrdpinc.h"
#include "xrdp_types.h"
#include "xrdp_constants.h"
@@ -36,7 +37,6 @@
#include "list.h"
#include "file.h"
#include "file_loc.h"
-#include "trans.h"
/* xrdp.c */
long APP_CC
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c
index a596eba0..1d3b3de1 100644
--- a/xrdp/xrdp_listen.c
+++ b/xrdp/xrdp_listen.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
listen for incoming connection
@@ -44,6 +44,11 @@ xrdp_listen_create(void)
{
g_process_sem = tc_sem_create(0);
}
+ self->listen_trans = trans_create(TRANS_MODE_TCP, 16, 16);
+ if (self->listen_trans == 0)
+ {
+ g_writeln("xrdp_listen_main_loop: trans_create failed");
+ }
return self;
}
@@ -51,6 +56,10 @@ xrdp_listen_create(void)
void APP_CC
xrdp_listen_delete(struct xrdp_listen* self)
{
+ if (self->listen_trans != 0)
+ {
+ trans_delete(self->listen_trans);
+ }
if (g_process_sem != 0)
{
tc_sem_delete(g_process_sem);
@@ -159,6 +168,32 @@ xrdp_listen_get_port(char* port, int port_bytes)
}
/*****************************************************************************/
+/* a new connection is coming in */
+int DEFAULT_CC
+xrdp_listen_conn_in(struct trans* self, struct trans* new_self)
+{
+ struct xrdp_process* process;
+ struct xrdp_listen* lis;
+
+ g_writeln("hello");
+ lis = (struct xrdp_listen*)(self->callback_data);
+ process = xrdp_process_create(lis, lis->pro_done_event);
+ if (xrdp_listen_add_pro(lis, process) == 0)
+ {
+ /* start thread */
+ process->server_trans = new_self;
+ g_process = process;
+ tc_thread_create(xrdp_process_run, 0);
+ tc_sem_dec(g_process_sem); /* this will wait */
+ }
+ else
+ {
+ xrdp_process_delete(process);
+ }
+ return 0;
+}
+
+/*****************************************************************************/
/* wait for incoming connections */
int APP_CC
xrdp_listen_main_loop(struct xrdp_listen* self)
@@ -166,32 +201,28 @@ xrdp_listen_main_loop(struct xrdp_listen* self)
int error;
int robjs_count;
int cont;
+ int timeout;
char port[8];
tbus robjs[8];
tbus term_obj;
tbus sync_obj;
tbus sck_obj;
tbus done_obj;
- struct xrdp_process* process;
self->status = 1;
- xrdp_listen_get_port(port, sizeof(port));
- self->sck = g_tcp_socket();
- g_tcp_set_non_blocking(self->sck);
- error = g_tcp_bind(self->sck, port);
- if (error != 0)
+ if (xrdp_listen_get_port(port, sizeof(port)) != 0)
{
- g_writeln("bind error in xrdp_listen_main_loop");
- g_tcp_close(self->sck);
+ g_writeln("xrdp_listen_main_loop: xrdp_listen_get_port failed");
self->status = -1;
return 1;
}
- error = g_tcp_listen(self->sck);
+ error = trans_listen(self->listen_trans, port);
if (error == 0)
{
+ self->listen_trans->trans_conn_in = xrdp_listen_conn_in;
+ self->listen_trans->callback_data = self;
term_obj = g_get_term_event();
sync_obj = g_get_sync_event();
- sck_obj = g_create_wait_obj_from_socket(self->sck, 0);
done_obj = self->pro_done_event;
cont = 1;
while (cont)
@@ -200,10 +231,15 @@ xrdp_listen_main_loop(struct xrdp_listen* self)
robjs_count = 0;
robjs[robjs_count++] = term_obj;
robjs[robjs_count++] = sync_obj;
- robjs[robjs_count++] = sck_obj;
robjs[robjs_count++] = done_obj;
+ timeout = -1;
+ if (trans_get_wait_objs(self->listen_trans, robjs, &robjs_count,
+ &timeout) != 0)
+ {
+ break;
+ }
/* wait */
- if (g_obj_wait(robjs, robjs_count, 0, 0, -1) != 0)
+ if (g_obj_wait(robjs, robjs_count, 0, 0, timeout) != 0)
{
/* error, should not get here */
g_sleep(100);
@@ -217,45 +253,19 @@ xrdp_listen_main_loop(struct xrdp_listen* self)
g_reset_wait_obj(sync_obj);
g_loop();
}
- if (g_is_wait_obj_set(sck_obj)) /* incomming connection */
- {
- error = g_tcp_accept(self->sck);
- if ((error == -1) && g_tcp_last_error_would_block(self->sck))
- {
- /* should not get here */
- g_sleep(100);
- }
- else if (error == -1)
- {
- /* error, should not get here */
- break;
- }
- else
- {
- process = xrdp_process_create(self, self->pro_done_event);
- if (xrdp_listen_add_pro(self, process) == 0)
- {
- /* start thread */
- process->sck = error;
- g_process = process;
- tc_thread_create(xrdp_process_run, 0);
- tc_sem_dec(g_process_sem); /* this will wait */
- }
- else
- {
- xrdp_process_delete(process);
- }
- }
- }
if (g_is_wait_obj_set(done_obj)) /* pro_done_event */
{
g_reset_wait_obj(done_obj);
xrdp_listen_delete_done_pro(self);
}
+ if (trans_check_wait_objs(self->listen_trans) != 0)
+ {
+ break;
+ }
}
/* stop listening */
- g_delete_wait_obj_from_socket(sck_obj);
- g_tcp_close(self->sck);
+ trans_delete(self->listen_trans);
+ self->listen_trans = 0;
/* second loop to wait for all process threads to close */
cont = 1;
while (cont)
diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c
index f3327767..f4cb6d5d 100644
--- a/xrdp/xrdp_mm.c
+++ b/xrdp/xrdp_mm.c
@@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2009
+ Copyright (C) Jay Sorg 2004-2010
module manager
@@ -660,13 +660,13 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s)
if (strcmp(ip, "127.0.0.1") == 0)
{
/* unix socket */
- self->chan_trans = trans_create(2, 8192, 8192);
+ self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
g_snprintf(port, 255, "/tmp/xrdp_chansrv_socket_%d", 7200 + display);
}
else
{
/* tcp */
- self->chan_trans = trans_create(1, 8192, 8192);
+ self->chan_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
g_snprintf(port, 255, "%d", 7200 + display);
}
self->chan_trans->trans_data_in = xrdp_mm_chan_data_in;
@@ -896,7 +896,7 @@ xrdp_mm_connect(struct xrdp_mm* self)
ok = 0;
errstr[0] = 0;
trans_delete(self->sesman_trans);
- self->sesman_trans = trans_create(1, 8192, 8192);
+ self->sesman_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
xrdp_mm_get_sesman_port(port, sizeof(port));
g_snprintf(text, 255, "connecting to sesman ip %s port %s", ip, port);
xrdp_wm_log_msg(self->wm, text);
diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c
index 8deb1ba2..c5eab510 100644
--- a/xrdp/xrdp_process.c
+++ b/xrdp/xrdp_process.c
@@ -56,6 +56,7 @@ xrdp_process_delete(struct xrdp_process* self)
g_delete_wait_obj(self->self_term_event);
libxrdp_exit(self->session);
xrdp_wm_delete(self->wm);
+ trans_delete(self->server_trans);
g_free(self);
}
@@ -111,6 +112,21 @@ xrdp_process_mod_end(struct xrdp_process* self)
}
/*****************************************************************************/
+static int DEFAULT_CC
+xrdp_process_data_in(struct trans* self)
+{
+ struct xrdp_process* pro;
+
+ DEBUG(("xrdp_process_data_in"));
+ pro = (struct xrdp_process*)(self->callback_data);
+ if (xrdp_process_loop(pro) != 0)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
int APP_CC
xrdp_process_main_loop(struct xrdp_process* self)
{
@@ -121,20 +137,19 @@ xrdp_process_main_loop(struct xrdp_process* self)
tbus robjs[32];
tbus wobjs[32];
tbus term_obj;
- tbus sck_obj;
+ DEBUG(("xrdp_process_main_loop"));
self->status = 1;
- self->session = libxrdp_init((long)self, self->sck);
+ self->server_trans->trans_data_in = xrdp_process_data_in;
+ self->server_trans->callback_data = self;
+ self->session = libxrdp_init((tbus)self, self->server_trans);
/* this callback function is in xrdp_wm.c */
self->session->callback = callback;
/* this function is just above */
self->session->is_term = xrdp_is_term;
- g_tcp_set_non_blocking(self->sck);
- g_tcp_set_no_delay(self->sck);
if (libxrdp_process_incomming(self->session) == 0)
{
term_obj = g_get_term_event();
- sck_obj = g_create_wait_obj_from_socket(self->sck, 0);
cont = 1;
while (cont)
{
@@ -143,10 +158,10 @@ xrdp_process_main_loop(struct xrdp_process* self)
robjs_count = 0;
wobjs_count = 0;
robjs[robjs_count++] = term_obj;
- robjs[robjs_count++] = sck_obj;
robjs[robjs_count++] = self->self_term_event;
xrdp_wm_get_wait_objs(self->wm, robjs, &robjs_count,
wobjs, &wobjs_count, &timeout);
+ trans_get_wait_objs(self->server_trans, robjs, &robjs_count, &timeout);
/* wait */
if (g_obj_wait(robjs, robjs_count, wobjs, wobjs_count, timeout) != 0)
{
@@ -161,25 +176,20 @@ xrdp_process_main_loop(struct xrdp_process* self)
{
break;
}
- if (g_is_wait_obj_set(sck_obj)) /* incomming client data */
+ if (xrdp_wm_check_wait_objs(self->wm) != 0)
{
- if (xrdp_process_loop(self) != 0)
- {
- break;
- }
+ break;
}
- if (xrdp_wm_check_wait_objs(self->wm) != 0)
+ if (trans_check_wait_objs(self->server_trans) != 0)
{
break;
}
}
- g_delete_wait_obj_from_socket(sck_obj);
libxrdp_disconnect(self->session);
}
xrdp_process_mod_end(self);
libxrdp_exit(self->session);
self->session = 0;
- g_tcp_close(self->sck);
self->status = -1;
g_set_wait_obj(self->done_event);
return 0;
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index 33dc2795..0e1d6b32 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -269,13 +269,13 @@ struct xrdp_wm
struct xrdp_process
{
int status;
- int sck;
+ struct trans* server_trans; /* in tcp server mode */
tbus self_term_event;
struct xrdp_listen* lis_layer; /* owner */
struct xrdp_session* session;
/* create these when up and running */
struct xrdp_wm* wm;
- int app_sck;
+ //int app_sck;
tbus done_event;
int session_id;
};
@@ -284,7 +284,7 @@ struct xrdp_process
struct xrdp_listen
{
int status;
- int sck;
+ struct trans* listen_trans; /* in tcp listen mode */
struct list* process_list;
tbus pro_done_event;
};