channel changes

This commit is contained in:
jsorg71 2008-12-16 02:18:36 +00:00
parent 9317386e74
commit 8090df64a5
5 changed files with 22 additions and 86 deletions

View File

@ -687,7 +687,8 @@ libxrdp_get_channel_id(struct xrdp_session* session, char* name)
/*****************************************************************************/ /*****************************************************************************/
int EXPORT_CC int EXPORT_CC
libxrdp_send_to_channel(struct xrdp_session* session, int channel_id, libxrdp_send_to_channel(struct xrdp_session* session, int channel_id,
char* data, int data_len) char* data, int data_len,
int total_data_len, int flags)
{ {
struct xrdp_rdp* rdp; struct xrdp_rdp* rdp;
struct xrdp_sec* sec; struct xrdp_sec* sec;
@ -704,11 +705,10 @@ libxrdp_send_to_channel(struct xrdp_session* session, int channel_id,
free_stream(s); free_stream(s);
return 1; return 1;
} }
/* here we make a copy of the data, xrdp_channel_send is /* here we make a copy of the data */
going to alter it if its bigger that 8192 or something */
out_uint8a(s, data, data_len); out_uint8a(s, data, data_len);
s_mark_end(s); s_mark_end(s);
if (xrdp_channel_send(chan, s, channel_id) != 0) if (xrdp_channel_send(chan, s, channel_id, total_data_len, flags) != 0)
{ {
free_stream(s); free_stream(s);
return 1; return 1;

View File

@ -58,7 +58,6 @@ struct mcs_channel_item
char name[16]; char name[16];
int flags; int flags;
int chanid; int chanid;
struct stream* in_s;
}; };
/* mcs */ /* mcs */
@ -402,7 +401,8 @@ xrdp_channel_delete(struct xrdp_channel* self);
int APP_CC int APP_CC
xrdp_channel_init(struct xrdp_channel* self, struct stream* s); xrdp_channel_init(struct xrdp_channel* self, struct stream* s);
int APP_CC int APP_CC
xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id); xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id,
int total_data_len, int flags);
int APP_CC int APP_CC
xrdp_channel_process(struct xrdp_channel* self, struct stream* s, xrdp_channel_process(struct xrdp_channel* self, struct stream* s,
int chanid); int chanid);

View File

@ -208,7 +208,8 @@ int DEFAULT_CC
libxrdp_get_channel_id(struct xrdp_session* session, char* name); libxrdp_get_channel_id(struct xrdp_session* session, char* name);
int DEFAULT_CC int DEFAULT_CC
libxrdp_send_to_channel(struct xrdp_session* session, int channel_id, libxrdp_send_to_channel(struct xrdp_session* session, int channel_id,
char* data, int data_len); char* data, int data_len,
int total_data_len, int flags);
int DEFAULT_CC int DEFAULT_CC
libxrdp_orders_send_brush(struct xrdp_session* session, libxrdp_orders_send_brush(struct xrdp_session* session,
int width, int height, int bpp, int type, int width, int height, int bpp, int type,

View File

@ -80,16 +80,11 @@ xrdp_channel_init(struct xrdp_channel* self, struct stream* s)
/*****************************************************************************/ /*****************************************************************************/
/* returns error */ /* returns error */
/* This sends data out to the secure layer, breaking up the data to /* This sends data out to the secure layer. */
CHANNEL_CHUNK_LENGTH as needed. This can end up sending many packets. */
int APP_CC int APP_CC
xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id) xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id,
int total_data_len, int flags)
{ {
int length;
int flags;
int thislength;
int remaining;
char* data;
struct mcs_channel_item* channel; struct mcs_channel_item* channel;
channel = xrdp_channel_get_item(self, channel_id); channel = xrdp_channel_get_item(self, channel_id);
@ -98,47 +93,16 @@ xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id)
return 1; return 1;
} }
s_pop_layer(s, channel_hdr); s_pop_layer(s, channel_hdr);
length = (int)((s->end - s->p) - 8); out_uint32_le(s, total_data_len);
thislength = MIN(length, CHANNEL_CHUNK_LENGTH);
remaining = length - thislength;
flags = (remaining == 0) ?
CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST;
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
{ {
flags |= CHANNEL_FLAG_SHOW_PROTOCOL; flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
} }
out_uint32_le(s, length);
out_uint32_le(s, flags); out_uint32_le(s, flags);
s->end = s->p + thislength;
data = s->end;
if (xrdp_sec_send(self->sec_layer, s, channel->chanid) != 0) if (xrdp_sec_send(self->sec_layer, s, channel->chanid) != 0)
{ {
return 1; return 1;
} }
while (remaining > 0)
{
thislength = MIN(remaining, CHANNEL_CHUNK_LENGTH);
remaining -= thislength;
flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0;
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
{
flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
}
if (xrdp_sec_init(self->sec_layer, s) != 0)
{
return 1;
}
out_uint32_le(s, length);
out_uint32_le(s, flags);
/* this is copying a later part of the stream up to the front */
out_uint8a(s, data, thislength);
s_mark_end(s);
if (xrdp_sec_send(self->sec_layer, s, channel->chanid) != 0)
{
return 1;
}
data += thislength;
}
return 0; return 0;
} }
@ -148,7 +112,8 @@ xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id)
ready. the default for this is a call to xrdp_wm.c. */ ready. the default for this is a call to xrdp_wm.c. */
static int APP_CC static int APP_CC
xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s, xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
int channel_id) int channel_id,
int total_data_len, int flags)
{ {
struct xrdp_session* session; struct xrdp_session* session;
int rv; int rv;
@ -162,17 +127,18 @@ xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
{ {
size = (int)(s->end - s->p); size = (int)(s->end - s->p);
/* in xrdp_wm.c */ /* in xrdp_wm.c */
rv = session->callback(session->id, 0x5555, channel_id, size, rv = session->callback(session->id, 0x5555,
(long)s->p, 0); MAKELONG(channel_id, flags),
size, (tbus)(s->p), total_data_len);
} }
else else
{ {
g_writeln("in xrdp_channel_process1, session->callback is nil"); g_writeln("in xrdp_channel_call_callback, session->callback is nil");
} }
} }
else else
{ {
g_writeln("in xrdp_channel_process1, session is nil"); g_writeln("in xrdp_channel_call_callback, session is nil");
} }
return rv; return rv;
} }
@ -180,9 +146,7 @@ xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
/*****************************************************************************/ /*****************************************************************************/
/* returns error */ /* returns error */
/* This is called from the secure layer to process an incomming non global /* This is called from the secure layer to process an incomming non global
channel packet. It copies the channel data to a special stream contained channel packet.
in the channel struct(the one in xrdp_mcs->channel_list) untill the
whole data message is ready.
'chanid' passed in here is the mcs channel id so it MCS_GLOBAL_CHANNEL 'chanid' passed in here is the mcs channel id so it MCS_GLOBAL_CHANNEL
plus something. */ plus something. */
int APP_CC int APP_CC
@ -191,10 +155,8 @@ xrdp_channel_process(struct xrdp_channel* self, struct stream* s,
{ {
int length; int length;
int flags; int flags;
int thislength;
int rv; int rv;
int channel_id; int channel_id;
struct stream* in_s;
struct mcs_channel_item* channel; struct mcs_channel_item* channel;
/* this assumes that the channels are in order of chanid(mcs channel id) /* this assumes that the channels are in order of chanid(mcs channel id)
@ -211,29 +173,6 @@ xrdp_channel_process(struct xrdp_channel* self, struct stream* s,
rv = 0; rv = 0;
in_uint32_le(s, length); in_uint32_le(s, length);
in_uint32_le(s, flags); in_uint32_le(s, flags);
if ((flags & CHANNEL_FLAG_FIRST) && (flags & CHANNEL_FLAG_LAST)) rv = xrdp_channel_call_callback(self, s, channel_id, length, flags);
{
rv = xrdp_channel_call_callback(self, s, channel_id);
}
else
{
if (channel->in_s == 0)
{
make_stream(channel->in_s);
}
in_s = channel->in_s;
if (flags & CHANNEL_FLAG_FIRST)
{
init_stream(in_s, length);
}
thislength = MIN(s->end - s->p, (in_s->data + in_s->size) - in_s->p);
out_uint8a(in_s, s->p, thislength);
if (flags & CHANNEL_FLAG_LAST)
{
in_s->end = in_s->p;
in_s->p = in_s->data;
rv = xrdp_channel_call_callback(self, in_s, channel_id);
}
}
return rv; return rv;
} }

View File

@ -61,11 +61,7 @@ xrdp_mcs_delete(struct xrdp_mcs* self)
{ {
channel_item = (struct mcs_channel_item*) channel_item = (struct mcs_channel_item*)
list_get_item(self->channel_list, index); list_get_item(self->channel_list, index);
if (channel_item != 0) g_free(channel_item);
{
free_stream(channel_item->in_s);
g_free(channel_item);
}
} }
list_delete(self->channel_list); list_delete(self->channel_list);
xrdp_iso_delete(self->iso_layer); xrdp_iso_delete(self->iso_layer);