27 |
#define CHANNEL_FLAG_LAST 0x02 |
#define CHANNEL_FLAG_LAST 0x02 |
28 |
#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10 |
#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10 |
29 |
|
|
30 |
extern BOOL use_rdp5; |
extern BOOL g_use_rdp5; |
31 |
extern BOOL g_encryption; |
extern BOOL g_encryption; |
32 |
|
|
33 |
VCHANNEL g_channels[MAX_CHANNELS]; |
VCHANNEL g_channels[MAX_CHANNELS]; |
34 |
unsigned int g_num_channels; |
unsigned int g_num_channels; |
35 |
|
|
36 |
/* FIXME: We should use the information in TAG_SRV_CHANNELS to map RDP5 |
/* FIXME: We should use the information in TAG_SRV_CHANNELS to map RDP5 |
37 |
channels to MCS channels. |
channels to MCS channels. |
38 |
|
|
39 |
The format of TAG_SRV_CHANNELS seems to be |
The format of TAG_SRV_CHANNELS seems to be |
40 |
|
|
48 |
{ |
{ |
49 |
VCHANNEL *channel; |
VCHANNEL *channel; |
50 |
|
|
51 |
if (!use_rdp5) |
if (!g_use_rdp5) |
52 |
return NULL; |
return NULL; |
53 |
|
|
54 |
if (g_num_channels >= MAX_CHANNELS) |
if (g_num_channels >= MAX_CHANNELS) |
87 |
s_pop_layer(s, channel_hdr); |
s_pop_layer(s, channel_hdr); |
88 |
length = s->end - s->p - 8; |
length = s->end - s->p - 8; |
89 |
|
|
90 |
thislength = MIN(length, CHANNEL_CHUNK_LENGTH); |
DEBUG_CLIPBOARD(("channel_send, length = %d\n", length)); |
91 |
|
|
92 |
|
thislength = MIN(length, CHANNEL_CHUNK_LENGTH); |
93 |
|
/* Note: In the original clipboard implementation, this number was |
94 |
|
1592, not 1600. However, I don't remember the reason and 1600 seems |
95 |
|
to work so.. This applies only to *this* length, not the length of |
96 |
|
continuation or ending packets. */ |
97 |
remaining = length - thislength; |
remaining = length - thislength; |
98 |
flags = (remaining == 0) ? CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST; |
flags = (remaining == 0) ? CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST; |
99 |
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) |
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) |
102 |
out_uint32_le(s, length); |
out_uint32_le(s, length); |
103 |
out_uint32_le(s, flags); |
out_uint32_le(s, flags); |
104 |
data = s->end = s->p + thislength; |
data = s->end = s->p + thislength; |
105 |
|
DEBUG_CLIPBOARD(("Sending %d bytes with FLAG_FIRST\n", thislength)); |
106 |
sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); |
sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); |
107 |
|
|
108 |
/* subsequent segments copied (otherwise would have to generate headers backwards) */ |
/* subsequent segments copied (otherwise would have to generate headers backwards) */ |
111 |
thislength = MIN(remaining, CHANNEL_CHUNK_LENGTH); |
thislength = MIN(remaining, CHANNEL_CHUNK_LENGTH); |
112 |
remaining -= thislength; |
remaining -= thislength; |
113 |
flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0; |
flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0; |
114 |
|
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) |
115 |
|
flags |= CHANNEL_FLAG_SHOW_PROTOCOL; |
116 |
|
|
117 |
|
DEBUG_CLIPBOARD(("Sending %d bytes with flags %d\n", thislength, flags)); |
118 |
|
|
119 |
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8); |
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8); |
120 |
out_uint32_le(s, length); |
out_uint32_le(s, length); |
167 |
in->p = in->data; |
in->p = in->data; |
168 |
} |
} |
169 |
|
|
170 |
thislength = s->end - s->p; |
thislength = MIN(s->end - s->p, in->data + in->size - in->p); |
171 |
memcpy(in->p, s->p, thislength); |
memcpy(in->p, s->p, thislength); |
172 |
s->p += thislength; |
in->p += thislength; |
|
s->end += thislength; |
|
173 |
|
|
174 |
if (flags & CHANNEL_FLAG_LAST) |
if (flags & CHANNEL_FLAG_LAST) |
175 |
{ |
{ |
176 |
|
in->end = in->p; |
177 |
in->p = in->data; |
in->p = in->data; |
178 |
channel->process(in); |
channel->process(in); |
179 |
} |
} |