xrdpapi: use header for server to client writes

ulab-next
Jay Sorg 12 years ago
parent 8a3ecc2a72
commit 4f6cbfd3fe

@ -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);

@ -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)

Loading…
Cancel
Save