2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Protocol services - Virtual channels |
Protocol services - Virtual channels |
4 |
Copyright (C) Erik Forsberg <forsberg@cendio.se> 2003 |
Copyright (C) Erik Forsberg <forsberg@cendio.se> 2003 |
5 |
Copyright (C) Matthew Chapman 2003-2005 |
Copyright (C) Matthew Chapman 2003-2008 |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
8 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
21 |
|
|
22 |
#include "rdesktop.h" |
#include "rdesktop.h" |
23 |
|
|
24 |
#define MAX_CHANNELS 5 |
#define MAX_CHANNELS 6 |
25 |
#define CHANNEL_CHUNK_LENGTH 1600 |
#define CHANNEL_CHUNK_LENGTH 1600 |
26 |
#define CHANNEL_FLAG_FIRST 0x01 |
#define CHANNEL_FLAG_FIRST 0x01 |
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 g_use_rdp5; |
extern RD_BOOL g_use_rdp5; |
31 |
extern BOOL g_encryption; |
extern RD_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; |
83 |
uint32 thislength, remaining; |
uint32 thislength, remaining; |
84 |
uint8 *data; |
uint8 *data; |
85 |
|
|
86 |
|
#ifdef WITH_SCARD |
87 |
|
scard_lock(SCARD_LOCK_CHANNEL); |
88 |
|
#endif |
89 |
|
|
90 |
/* first fragment sent in-place */ |
/* first fragment sent in-place */ |
91 |
s_pop_layer(s, channel_hdr); |
s_pop_layer(s, channel_hdr); |
92 |
length = s->end - s->p - 8; |
length = s->end - s->p - 8; |
93 |
|
|
94 |
DEBUG_CLIPBOARD(("channel_send, length = %d\n", length)); |
DEBUG_CHANNEL(("channel_send, length = %d\n", length)); |
95 |
|
|
96 |
thislength = MIN(length, CHANNEL_CHUNK_LENGTH); |
thislength = MIN(length, CHANNEL_CHUNK_LENGTH); |
97 |
/* Note: In the original clipboard implementation, this number was |
/* Note: In the original clipboard implementation, this number was |
106 |
out_uint32_le(s, length); |
out_uint32_le(s, length); |
107 |
out_uint32_le(s, flags); |
out_uint32_le(s, flags); |
108 |
data = s->end = s->p + thislength; |
data = s->end = s->p + thislength; |
109 |
DEBUG_CLIPBOARD(("Sending %d bytes with FLAG_FIRST\n", thislength)); |
DEBUG_CHANNEL(("Sending %d bytes with FLAG_FIRST\n", thislength)); |
110 |
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); |
111 |
|
|
112 |
/* subsequent segments copied (otherwise would have to generate headers backwards) */ |
/* subsequent segments copied (otherwise would have to generate headers backwards) */ |
118 |
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) |
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) |
119 |
flags |= CHANNEL_FLAG_SHOW_PROTOCOL; |
flags |= CHANNEL_FLAG_SHOW_PROTOCOL; |
120 |
|
|
121 |
DEBUG_CLIPBOARD(("Sending %d bytes with flags %d\n", thislength, flags)); |
DEBUG_CHANNEL(("Sending %d bytes with flags %d\n", thislength, flags)); |
122 |
|
|
123 |
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8); |
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8); |
124 |
out_uint32_le(s, length); |
out_uint32_le(s, length); |
129 |
|
|
130 |
data += thislength; |
data += thislength; |
131 |
} |
} |
132 |
|
|
133 |
|
#ifdef WITH_SCARD |
134 |
|
scard_unlock(SCARD_LOCK_CHANNEL); |
135 |
|
#endif |
136 |
} |
} |
137 |
|
|
138 |
void |
void |