summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2012-12-17 17:29:24 -0800
committerJay Sorg <jay.sorg@gmail.com>2012-12-17 17:29:24 -0800
commit4f6cbfd3fe7041de98537731574e63485a6dcc82 (patch)
tree0f2fb8ad85a162af60da040b06a68c9774f4ac75
parent8a3ecc2a728265aed1ebb043a899ad888e8c2f66 (diff)
downloadxrdp-proprietary-4f6cbfd3fe7041de98537731574e63485a6dcc82.tar.gz
xrdp-proprietary-4f6cbfd3fe7041de98537731574e63485a6dcc82.zip
xrdpapi: use header for server to client writes
-rw-r--r--sesman/chansrv/chansrv.c26
-rw-r--r--xrdpapi/xrdpapi.c17
2 files changed, 41 insertions, 2 deletions
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c
index 8bcdb62b..9d55388e 100644
--- a/sesman/chansrv/chansrv.c
+++ b/sesman/chansrv/chansrv.c
@@ -54,6 +54,9 @@ static tbus g_thread_done_event = 0;
static int g_use_unix_socket = 0;
+static char g_xrdpapi_magic[12] =
+{ 0x78, 0x32, 0x10, 0x67, 0x00, 0x92, 0x30, 0x56, 0xff, 0xd8, 0xa9, 0x1f };
+
int g_display_num = 0;
int g_cliprdr_chan_id = -1; /* cliprdr */
int g_rdpsnd_chan_id = -1; /* rdpsnd */
@@ -585,6 +588,7 @@ my_api_trans_data_in(struct trans *trans)
{
struct stream *s;
int bytes_read;
+ int i32;
struct xrdp_api_data *ad;
//g_writeln("my_api_trans_data_in:");
@@ -604,7 +608,27 @@ my_api_trans_data_in(struct trans *trans)
LOGM((LOG_LEVEL_DEBUG, "my_api_trans_data_in:"));
s = trans_get_in_s(trans);
- bytes_read = g_tcp_recv(trans->sck, s->data, 8192 * 4, 0);
+ bytes_read = g_tcp_recv(trans->sck, s->data, 16, 0);
+ if (bytes_read == 16)
+ {
+ if (g_memcmp(s->data, g_xrdpapi_magic, 12) == 0)
+ {
+ in_uint8s(s, 12);
+ in_uint32_le(s, bytes_read);
+ init_stream(s, bytes_read);
+ trans_force_read(trans, bytes_read);
+ }
+ else if (g_tcp_select(trans->sck, 0) & 1)
+ {
+ i32 = bytes_read;
+ bytes_read = g_tcp_recv(trans->sck, s->data + bytes_read,
+ 8192 * 4 - bytes_read, 0);
+ if (bytes_read > 0)
+ {
+ bytes_read += i32;
+ }
+ }
+ }
//g_writeln("bytes_read %d", bytes_read);
diff --git a/xrdpapi/xrdpapi.c b/xrdpapi/xrdpapi.c
index 973deb48..610a8078 100644
--- a/xrdpapi/xrdpapi.c
+++ b/xrdpapi/xrdpapi.c
@@ -53,6 +53,9 @@ static int send_init(struct wts_obj *wts);
static int can_send(int sck, int millis);
static int can_recv(int sck, int millis);
+static char g_xrdpapi_magic[12] =
+{ 0x78, 0x32, 0x10, 0x67, 0x00, 0x92, 0x30, 0x56, 0xff, 0xd8, 0xa9, 0x1f };
+
/*
* Opens a handle to the server end of a specified virtual channel - this
* call is deprecated - use WTSVirtualChannelOpenEx() instead
@@ -163,6 +166,7 @@ WTSVirtualChannelWrite(void *hChannelHandle, const char *Buffer,
{
struct wts_obj *wts;
int rv;
+ int header[4];
wts = (struct wts_obj *) hChannelHandle;
@@ -185,7 +189,18 @@ WTSVirtualChannelWrite(void *hChannelHandle, const char *Buffer,
return 0; /* can't write now, ok to try again */
}
- rv = send(wts->fd, Buffer, Length, 0);
+ memcpy(header, g_xrdpapi_magic, 12);
+ header[3] = Length;
+ if (send(wts->fd, header, 16, 0) == 16)
+ {
+ rv = send(wts->fd, Buffer, Length, 0);
+ }
+ else
+ {
+ LLOGLN(0, ("WTSVirtualChannelWrite: header write failed"));
+ return -1;
+ }
+
LLOGLN(10, ("WTSVirtualChannelWrite: send() reted %d", rv));
if (rv >= 0)